zsr :: ~ ‹master*› % ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa): ~/.ssh/githubsshkey # 填写路径,可以指定文件名,可以缺省(缺省默认为 id_rsa) Enter passphrase (empty for no passphrase): # 密码可为空 Enter same passphrase again: # 密码可为空 Your identification has been saved in ~/.ssh/githubsshkey. Your public key has been saved in ~/.ssh/githubsshkey.pub. The key fingerprint is: SHA256:Va57YAfyxN86cD5a1ejR6imhQiJuM/2IeTyK5FI+W+4 zsr@zsr.local The key's randomart image is: +---[RSA 2048]----+ | . | | . o | | . = . | | = + . + | | S * + = o| | . . . .. B.+ o | | o...+ o ..B.o | |.oo+=o=.. .+.+ . | | .+=E=.o... .o | +----[SHA256]-----+
然后根据提示连续回车即可在~/.ssh 目录下得到 githubsshkey 和 githubsshkey.pub 其中 githubsshkey.pub 文件里面存放的就是我们要使用的 public key。
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: POSSIBLE DNS SPOOFING DETECTED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The ECDSA host key for [g.hz.netease.com]:22222 has changed, and the key for the corresponding IP address [59.111.178.110]:22222 is unknown. This could either mean that DNS SPOOFING is happening or the IP address for the host and its host key have changed at the same time. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:iktCbxKzaP13xO9iY/5B9tkuIYE9BZfC31uW1Z6F4YQ. Please contact your system administrator. Add correct host key in ~/.ssh/known_hosts to get rid of this message. Offending ECDSA key in ~/.ssh/known_hosts:20 ECDSA host key for [g.hz.netease.com]:22222 has changed and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository.