ssh-keygen -t rsa -C "firstname.lastname@example.org"# 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):
# Your identification has been saved in /home/you/.ssh/id_rsa.# Your public key has been saved in /home/you/.ssh/id_rsa.pub.# The key fingerprint is:# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db email@example.com
# start the ssh-agent in the backgroundeval "$(ssh-agent -s)"# Agent pid 59566ssh-add ~/.ssh/id_rsa
sudo apt-get install xclip# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)xclip -sel clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard
然后打开你github设置页面，里面有个SSH keys 如图
然后点击Add SSH key 把刚刚复制的粘贴进去就可以了。
ssh -T firstname.lastname@example.org# Attempts to ssh to github
... Agent admitted failure to sign using the key. debug1: No more authentication methods to try. Permission denied (publickey).
# The authenticity of host 'github.com (220.127.116.11)' can't be established.# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.# Are you sure you want to continue connecting (yes/no)?
# Hi username! You've successfully authenticated, but GitHub does not# provide shell access.