Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/zhangsisi/.ssh/id_rsa): 按回车键 /c/Users/zhangsisi/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): 输入密码 Enter same passphrase again:再次输入密码
输入密码后结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Your identification has been saved in /c/Users/zhangsisi/.ssh/id_rsa. Your public key has been saved in /c/Users/zhangsisi/.ssh/id_rsa.pub. The key fingerprint is: fingerprint值 your_email@163.com The key's randomart image is: +---[RSA 2048]----+ | ....o +.| | . . . + = o| | o o o = + | | o = .+ * +| | o B .S .+.+ =.| | o = ....*o+ | | o o o.. +oE | | * . .+ | | .+ ..o| +----[SHA256]-----+
1
id_rsa 文件时私有密钥 id_rsa.pub是公有密钥
2、获取公有密钥
1 2 3
$ cat ~/.ssh/id_rsa.pub
ssh-rsa 公开密钥内容 zhangsisi3034@163.com
3、GitHub添加公开密钥
点击GitHub有上角账户设置按钮(Setting),选择SSH and GPG keys,点击add ssh Key,出现如下内容。
4、测试认证成功
1 2 3 4 5 6 7
$ ssh -T git@github.com //成功实例 The authenticity of host 'github.com (52.74.223.119)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts. Enter passphrase for key '/c/Users/zhangsisi/.ssh/id_rsa':
出现下面结果证明成功
1
Hi GraceSi! You've successfully authenticated, but GitHub does not provide shell access.