我正在尝试通过 ssh 连接到远程服务器。
- 我正在使用我的
id_rsa
公钥,我已经用它连接到 GitHub 和 Bitbucket - 通过提供商的仪表板访问服务器,并将内容添加
id_rsa.pub
到~/.ssh/authorized_keys
- 回到我的电脑前,尝试了一下
ssh user@ip
,得到了一个user@ip: Permission denied (publickey)
因此,
ssh user@ip -v
返回以下内容(最后几行):debug1: Next authentication method: publickey debug1: Offering public key: RSA SHA256:blablablabla /home/username/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /home/username/.ssh/id_dsa debug1: Trying private key: /home/username/.ssh/id_ecdsa debug1: Trying private key: /home/username/.ssh/id_ed25519 debug1: No more authentication methods to try. user@ip: Permission denied (publickey).
另外:本地id_rsa.pub
权限为 600,服务器权限.ssh/
为 700,服务器权限authorized_keys
为 744
我这里遗漏了什么吗?
答案1
在我看来,这就像尝试了你的密钥,但随后被拒绝:
user@ip: Permission denied (publickey).
重新添加您的密钥,看看是否正确。如果不是,请添加更多 -v(根据手册页):
-v Verbose mode. Causes ssh to print debugging messages about its progress. This is helpful in debugging connection, authentication,
and configuration problems. Multiple -v options increase the verbosity. The maximum is 3.