我的环境是阿里云centos7。
1、生成ssh-key
,填入自己的邮箱
ssh-keygen -t rsa -C "xxxxxx@126.com"
2、进入ssh
目录
cd ~/.ssh
3、查看文件
ls
会看到列举出了有id_rsa
、id_rsa.pub
。
4、复制一下id_rsa.pub
文件内容
cat id_rsa.pub
5、打开github
中的SSH and GPS keys
选项,新增SSH key
,添加完成需要再次输入github
密码验证。
6、在自己的终端测试一下吧,使用ssh -T git@github.com
[root@iZuf60c5nb7ulqwzl2jwbsZ .ssh]# ssh -T git@github.com
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5: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)? yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Hi solocao! You've successfully authenticated, but GitHub does not provide shell access.
[root@iZuf60c5nb7ulqwzl2jwbsZ .ssh]# ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
Hi solocao! You've successfully authenticated, but GitHub does not provide shell access.