![在 Windows 计算机上使用 Git Bash 进行 SSH 时权限被拒绝(公钥)](https://linux22.com/image/1594389/%E5%9C%A8%20Windows%20%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%B8%8A%E4%BD%BF%E7%94%A8%20Git%20Bash%20%E8%BF%9B%E8%A1%8C%20SSH%20%E6%97%B6%E6%9D%83%E9%99%90%E8%A2%AB%E6%8B%92%E7%BB%9D%EF%BC%88%E5%85%AC%E9%92%A5%EF%BC%89.png)
当我尝试执行命令时ssh -vvv user@ip_address
,结果的最后几行如下所示:
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
user@ip_address: Permission denied (publickey).
我也尝试使用 Putty 并验证了 下的公钥/home/username/.ssh/authorized_keys
。我该如何解决这个问题?
答案1
终于解决了。尝试了以下步骤:
将下面的文件夹复制
/root/.ssh
到/home/username/.ssh
。把的权限改为
.ssh
700,并将其下的文件的权限改为644。在本地机器上,我在显示我的公钥的屏幕上从 putty gen 执行了“转换-->导出 openssh 密钥”,该公钥是之前从 putty gen 生成的。
将 openssh 密钥复制到
~/.ssh/
,然后将文件内容复制到id_rsa
同一路径下,即 .ssh在 .ssh 下创建了一个配置文件,如下所示:
#!/bin/sh Hostname ip_address of remote server User username PubKeyAuthentication yes IdentityFile ~/.ssh/id_rsa
最后尝试使用命令进行连接
ssh -vvv username@remoteserver_ip_address