自学内容网 自学内容网

git通过ssh方式操作提示Permission denied (publickey). 【解决】

问题:

C:\Users\admin>git clone "ssh://xxxx.com:22518/xxxx"
Cloning into 'xxxx'...
xxx@xxxxx.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

问题解决:

1 首先检查上传的ssh的公钥是否正确,注意不要多了换行符

2 通过命令查看

C:\Users\admin>ssh -v xxxx@xxxx.com -p 22518
....
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\admin/.ssh/id_rsa RSA SHA256:HPF6dYbfpIyS9fUIY0Q6upoXs+ccffkg3Ju9KF0Qy/0
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: C:\\Users\\admin/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\admin/.ssh/id_ecdsa_sk
debug1: Trying private key: C:\\Users\\admin/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\admin/.ssh/id_ed25519_sk
debug1: Trying private key: C:\\Users\\admin/.ssh/id_xmss
debug1: Trying private key: C:\\Users\\admin/.ssh/id_dsa
debug1: No more authentication methods to try.

从上面的提示钟看到 “debug1: send_pubkey_test: no mutual signature algorithm”,也需要检查公钥是否显示algorithm算法

这表示没有无相互签名算法

采用命令查看是否成功,指定指定公钥认证所接受的密钥类型PubkeyAcceptedKeyTypes=+ssh-rsa

C:\Users\admin>ssh -o PubkeyAcceptedKeyTypes=+ssh-rsa -v xxxx@xxxx.com -p 22518
....
debug1: ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported. Console supports the ansi parsing

  ****    Welcome to Gerrit Code Review    ****

  Hi liulun_ext, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://xxx@xxxx.com:22518/REPOSITORY_NAME.git

可以看出成功了

3 找到问题,开始完美解决

在你的.ssh文件夹中,新建config文件

Host *
  HostkeyAlgorithms +ssh-rsa
  PubkeyAcceptedKeyTypes +ssh-rsa

4 效果

C:\Users\admin>git clone "ssh://xxxx@xxxx.com:22518/xxxx"
Cloning into 'xxxx_service'...
remote: Counting objects: 340, done
remote: Finding sources: 100% (273/273)


原文地址:https://blog.csdn.net/liu289747235/article/details/142998477

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!