原因分析


出现这个问题一般是两个原因造成:

  1. 公钥不匹配
  2. 服务端或客户端公钥未生成

知道问题所在也就知道了怎么去解决了

解决方法

客户端生成ssh-key

ssh-keygen -t rsa -C "你注册的邮箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/path/.ssh/id_rsa): 文件生成别名
Enter passphrase (empty for no passphrase):密码(直接回车跳过)
Enter same passphrase again:密码(直接回车跳过)
Your identification has been saved in github.
Your public key has been saved in github.pub.
The key fingerprint is:
SHA256:E9KpYQTd1Dh6ZOaLk6gL9bTjORzfaWE/P5oGulfyYfo 你注册的邮箱
The key's randomart image is:
+---[RSA 3072]----+
|    .o.o.o       |
|     ...B..      |
|      +*+.       |
|     ..+o.       |
|  . ...+S.       |
| . oo.+ *.+      |
|.  o+o = @ .     |
| ...ooo * =..    |
|  ..o..+ oE+..   |
+----[SHA256]-----+

服务端配置客户端的ssh-key

ssh.png

ssh2.png

本地添加私钥

ssh-add 私钥文件名称

本地验证Key

ssh -T git@github.com # github
ssh -T git@gitee.com # 码云

出现Hi CoderSamYhc! You've successfully authenticated, but GitHub does not provide shell access.

最后修改:2020 年 10 月 16 日 07 : 34 PM
如果觉得我的文章对你有用,请随意赞赏