我知道这个问题已经讨论过了。我查看了其他帖子,没有找到相同问题的问题,希望您能帮助我...
我通过 SSH 从用户A@主机A到用户B@主机B。两台主机使用相同的文件系统,这意味着用户 A 的主目录在主机 A 和主机 B 上相同,并且与用户 B 的主目录相同。
现在,我想将密钥保存在 B 的 .ssh 目录上,这样我就可以在没有密码的情况下从 A@A 访问 B@B,所以我在 userA@hostA 上执行了以下操作:
ssh-keygen -t rsa -b 2048
ssh-copy-id -i ~/.ssh/id_rsa userB@hostB
echo $? ### output was 0, meaning it was successfull
ssh -v userB@hostB
并得到以下输出:
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to hostB [100.100.100.100] port 22.
debug1: Connection established.
debug1: identity file /home/userA/.ssh/identity type -1
debug1: identity file /home/userA/.ssh/identity-cert type -1
debug1: identity file /home/userA/.ssh/id_rsa type 1
debug1: identity file /home/userA/.ssh/id_rsa-cert type -1
debug1: identity file /home/userA/.ssh/id_dsa type -1
debug1: identity file /home/userA/.ssh/id_dsa-cert type -1
debug1: identity file /home/userA/.ssh/id_ecdsa type -1
debug1: identity file /home/userA/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'hostB' is known and matches the RSA host key.
debug1: Found key in /home/userA/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
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 information
Credentials cache file '/tmp/krb5cc_524' not found
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_524' not found
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_524' not found
debug1: Next authentication method: publickey
debug1: Trying private key: /home/userA/.ssh/identity
debug1: Offering public key: /home/userA/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/userA/.ssh/id_dsa
debug1: Trying private key: /home/userA/.ssh/id_ecdsa
debug1: Next authentication method: password
userB@hostB's password:
请注意,我确实设法对 userA@hostB 进行无密码访问,但在访问 userB 时却没有...
有任何想法吗?
多谢!
附言。一些附加信息:
主机A版本:
Linux 版本 2.6.32-573.7.1.el6.x86_64([电子邮件受保护]) (gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP 9 月 22 日星期二 22:00:00 UTC 2015
主机B版本:
Linux 版本 2.6.32-358.el6.x86_64([电子邮件受保护]) (gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP 2013 年 1 月 29 日星期二 11:47:41 EST
在 userB@hostB 上(我想这就是 Jakuje 的意思),访问目录和文件:
~: drwxrwx---
~/.ssh: drwx------
~/.ssh/authorized_keys: -rw-------