【问题标题】:fail to ssh remote host with error message "Permission denied (publickey)"无法 ssh 远程主机并显示错误消息“权限被拒绝(公钥)”
【发布时间】:2013-12-01 02:18:22
【问题描述】:

最近,我遇到了 ssh 远程主机的问题。

首先,当 /etc/ssh/sshd_config 文件中的“PasswordAuthentication”参数为“yes”时,我可以 ssh 远程主机。

但是,在 /etc/ssh/sshd_config 文件中将“PasswordAuthentication”参数更改为“no”后,我无法 ssh 远程主机。

我知道我的问题是关于 PublicKey,因为我的 /etc/ssh/sshd_config 文件中有这些参数:

RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes

“# ssh root@172.17.4.17 -VVV”的结果是这样的,

debug1: Server host key: RSA 8a:bb:7f:d0:61:69:cc:b2:a1:a0:16:be:52:c1:5c:94
debug3: load_hostkeys: loading entries for host "172.17.4.17" from file "/home/jundu/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/jundu/.ssh/known_hosts:12
debug3: load_hostkeys: loaded 1 keys
debug1: Host '172.17.4.17' is known and matches the RSA host key.
debug1: Found key in /home/jundu/.ssh/known_hosts:12
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/jundu/.ssh/id_rsa ((nil))
debug2: key: /home/jundu/.ssh/id_dsa ((nil))
debug2: key: /home/jundu/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/jundu/.ssh/id_rsa
debug3: no such identity: /home/jundu/.ssh/id_rsa
debug1: Trying private key: /home/jundu/.ssh/id_dsa
debug3: no such identity: /home/jundu/.ssh/id_dsa
debug1: Trying private key: /home/jundu/.ssh/id_ecdsa
debug3: no such identity: /home/jundu/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

权限被拒绝(公钥)?我只是不知道这是什么意思。谁能给我一些建议?提前谢谢!

【问题讨论】:

  • 看起来服务器只想让您使用公钥,而您没有公钥。

标签: public-key openssh


【解决方案1】:

在某些使用ssh的情况下,当我们遇到Permission denied (publickey)?的问题时,意味着两件事:

1) 我们正在使用 ssh 密钥对来访问远程主机。

2) 我们从不让远程主机知道我们本地主机的公钥,也没有私钥可以访问。

解决方案:

step1:将公钥复制到远程主机(通常在~/.ssh/authorized_key)

第二步:将对应的私钥粘贴到本地主机的~/.ssh/id_rsa(或id_dsa)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-08
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    相关资源
    最近更新 更多