我在集群上运行,其中我的主目录共享给所有机器。一些机器是 RHEL,其他是 Ubuntu。
当我从 RHEL->RHEL 或 UBUNTU->RHEL 无需密码登录时,登录成功。但是,当我尝试从 any->UBUNTU 时,登录失败,我需要手动输入密码。
EDIT1:仅当尝试连接某些 Ubuntu 机器时才会失败。 连接其他 Ubuntu 机器则成功。
我确认将~
和的设置~/.ssh
为chmod 700
和authorized_keys
设置为chmod 600
,但没有帮助。
EDIT2:我在下面添加了输出 namei -lx ~/.ssh/authorized_keys
EDIT3:我在一台有 sudo 的机器上添加了下面 ssh 的调试模式输出。令人惊讶的是(尽管在上面),它显示Authentication refused: bad ownership or modes for file /home/lab/my_user/.ssh/authorized_keys
。
我删除并重新创建了 ssh 密钥,但同样没有成功(ssh 到非 sudo 机器仍然有效,ssh 到带 sudo 的机器无效)。我使用的命令是:
ssh-keygen -t rsa
ssh-copy-id -i id_rsa.pub ubuntu_machine_name
以下是执行时的输出ssh -vv host
[my_user@ctx01 .ssh]$ ssh -vv 10.20.30.40
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options or *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.20.30.40 [10.20.30.40] port 22.
debug1: Connection established.
debug1: identity file /home/lab/my_user/.ssh/identity type -1
debug1: identity file /home/lab/my_user/.ssh/identity-cert type -1
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /home/lab/my_user/.ssh/id_rsa type 1
debug1: identity file /home/lab/my_user/.ssh/id_rsa-cert type -1
debug1: identity file /home/lab/my_user/.ssh/id_dsa type -1
debug1: identity file /home/lab/my_user/.ssh/id_dsa-cert type -1
debug1: identity file /home/lab/my_user/.ssh/id_ecdsa type -1
debug1: identity file /home/lab/my_user/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
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
debug2: dh_gen_key: priv key bits set: 130/256
debug2: bits set: 480/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.20.30.40' is known and matches the RSA host key.
debug1: Found key in /home/lab/my_user/.ssh/known_hosts:1
debug2: bits set: 519/1024
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: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-my_userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/lab/my_user/.ssh/identity ((nil))
debug2: key: /home/lab/my_user/.ssh/id_rsa (0x7f412fd53880)
debug2: key: /home/lab/my_user/.ssh/id_dsa ((nil))
debug2: key: /home/lab/my_user/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/lab/my_user/.ssh/identity
debug1: Offering public key: /home/lab/my_user/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/lab/my_user/.ssh/id_dsa
debug1: Trying private key: /home/lab/my_user/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: password
[email protected]'s password:
以下是输出namei -lx ~/.ssh/authorized_keys
f: /home/lab/my_user/.ssh/authorized_keys
Drwxr-xr-x root root /
drwxr-xr-x root root home
Drwxr-xr-x nobody nogroup lab
drwx------ nobody nogroup my_user
drwx------ nobody nogroup .ssh
-rw------- nobody nogroup authorized_keys
以下是 ssh 在调试模式下的输出:
debug1: userauth-request for user my_user service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: test whether pkalg/pkblob are acceptable [preauth]
debug1: temporarily_use_uid: 2117/505 (e=0/0)
debug1: trying public key file /home/lab/my_user/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
Authentication refused: bad ownership or modes for file /home/lab/my_user/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 2117/505 (e=0/0)
debug1: trying public key file /home/lab/my_user/.ssh/authorized_keys2
debug1: Could not open authorized keys '/home/lab/my_user/.ssh/authorized_keys2': No such file or directory
debug1: restore_uid: 0/0
Failed publickey for my_user from 10.20.30.40 port 48718 ssh2: RSA 90:42:ea:e3:79:b2:27:67:49:1b:17:0b:db:b6:ad:eb
答案1
该问题与 Ubuntu 计算机上的 NFS 配置不正确有关。当我这样做时,ls -l
文件所有者和组是nobody nogroup
。一旦我修复了 NFS 配置,一切都会顺利进行。