错误
Err
在添加github ssh key 的时候,报错
29676@XiaoSheng MINGW64 /d/itcast/testc/aaa
$ ssh -T git@github.com
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:ptyyusjkddksancjjddVc98/R1Brtyuiu3/LrtKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # 注意这里要填yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
解决方法
$ ssh -v git@github.com
会打印出以下信息
$ ssh -v git@github.com
OpenSSH_8.4p1, OpenSSL 1.1.1i 8 Dec 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [20.205.243.166] port 22.
debug1: Connection established.
debug1: identity file /c/Users/29676/.ssh/id_rsa type 0
debug1: identity file /c/Users/29676/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_dsa type -1
debug1: identity file /c/Users/29676/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/29676/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/29676/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/29676/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/29676/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/29676/.ssh/id_xmss type -1
debug1: identity file /c/Users/29676/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4
debug1: Remote protocol version 2.0, remote software version babeld-4f04c79d
debug1: no match: babeld-4f04c79d
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ertyuiopgd1TJYWeIOttrVc98/RrtyuWu3/LiyKgUfQM
debug1: Host 'github.com' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/29676/.ssh/known_hosts:14
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/29676/.ssh/id_rsa RSA SHA256:Kne/u9Ertyuiopf8n34BpfghjkIbIeDMcl92FnrALkk
debug1: Will attempt key: /c/Users/29676/.ssh/id_dsa
debug1: Will attempt key: /c/Users/29676/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/29676/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/29676/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/29676/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/29676/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/29676/.ssh/id_rsa RSA SHA256:Kne/cvbnmjhgftyuddfaspxsjGfIbIeDMcl92FnrALkk
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/29676/.ssh/id_dsa
debug1: Trying private key: /c/Users/29676/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/29676/.ssh/id_ecdsa_sk
debug1: Trying private key: /c/Users/29676/.ssh/id_ed25519
debug1: Trying private key: /c/Users/29676/.ssh/id_ed25519_sk
debug1: Trying private key: /c/Users/29676/.ssh/id_xmss
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
使用debug1: Trying private key: /c/Users/29676/.ssh/id_dsa
提示的文件名id_dsa
gitee
是可以正常访问的
然后
$ ssh -T git@github.com
Hi xsxiaosheng! You've successfully authenticated, but GitHub does not provide shell access.
gitee、github
两套ssh
共存
- 首先进入
C:/USER/XXX/.ssh
-
执行
ssh-keygen -t rsa -C "2967615343@qq.com" -f "github_id_rsa"
ssh-keygen -t rsa -C "2967615343@qq.com" -f "gitee_id_rsa"
- 创建
known_hosts
文件
打开,填入
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
- 测试
ssh -T git@github.com
ssh -T git@gitee.com
注意
Hi xsxiaosheng! You've successfully authenticated, but GitHub does not provide shell access.
这样提示是正常的,这样的意思就是,你可以访问,但是不能给你提功ssh登录权限
1 条评论
风铃 · 2022-04-02 21:09
学到了,感谢,感谢分享,
评论已关闭。