无法使用错误消息ssh远程主机"权限被拒绝(公钥)"

时间:2013-11-18 02:39:31

标签: public-key openssh

最近,我遇到了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).

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

1 个答案:

答案 0 :(得分:0)

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

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

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

解决方案:

步骤1:将公钥复制到远程主机(通常在〜/ .ssh / authorized_key中)

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