参考:https://help.github.com/articles/generating-ssh-keys#platform-linux
1、生成ssh key
ssh-keygen -t rsa -C "your_email@example.com" # Creates a new ssh key, using the provided email as a label # Generating public/private rsa key pair. # Enter file in which to save the key (/home/you/.ssh/id_rsa):Enter passphrase (empty for no passphrase): [Type a passphrase] # Enter same passphrase again: [Type passphrase again]
2、添加 new key 到 ssh-agent
ssh-add ~/.ssh/id_rsa
3、将pub key 上传到github
将 ~/.ssh/id_rsa.pub 中的内容粘贴到github ssh key中
4、测试连接是否正常
ssh -T git@github.com # Attempts to ssh to github
5、同步服务器中的仓库:
$ git config --global user.name "your name"
$ git config --global user.email "your_email@youremail.com"
$ git clone git@github.com:yourname/yourRepo.git
6、提交上传:
git add README
git commit -m "first commit"
git push origin master