从 abc@server1 到 xyz@server2 的 ssh 无密码连接无法正常工作

从 abc@server1 到 xyz@server2 的 ssh 无密码连接无法正常工作

从 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)

相关内容