![从 abc@server1 到 xyz@server2 的 ssh 无密码连接无法正常工作](https://linux22.com/image/163936/%E4%BB%8E%20abc%40server1%20%E5%88%B0%20xyz%40server2%20%E7%9A%84%20ssh%20%E6%97%A0%E5%AF%86%E7%A0%81%E8%BF%9E%E6%8E%A5%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
从 abc@server1 到 xyz@server2 的 ssh 无密码连接无法正常工作,我使用 RSA 生成密钥并id_rsa.pub
从 server1 复制到 server2。仍然不起作用
生成的密钥如下
cd
ssh-keygen -t rsa
ssh-keygen -t rsa1
ssh-keygen -t dsa
scp id_rsa.pub xyz@server2 :/.ssh/authorized_keys
然后尝试ssh
从用户server1
身份做到abc
xyz@server2
它仍然询问 pwd
------到server3它的工作-------------
debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:RuHlMx/4SvyHbc6If32cdbAzW8p1ogG1zvIGYxULr3E /qcm/svprd/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to server3 ([172.10.10.10]:22).
------ 到 server2 不工作-------------
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more informationNo Kerberos credentials available
答案1
如果您没有 ssh-copy-id,正确的scp
命令是
scp id_rsa.pub xyz@server2:.ssh/authorized_keys
提供
.ssh
存在于 server2 上 xyz 的 HOME 目录中.ssh
是 700 (drwx------
) (chmod u+rwx,go-rwx .ssh
)authorized_keys
是 600 (chmod 600 authorized_keys
)