如果 /home 目录已安装 ceph,则 ssh 不会与 RSA 密钥对连接

如果 /home 目录已安装 ceph,则 ssh 不会与 RSA 密钥对连接

我遇到的问题是,在我维护的服务器上,切换到主目录的 Ceph 文件系统后,通过 RSA 密钥的 ssh 登录突然停止工作。我尝试检查了几件事,但我在互联网上找到的解决方案都不起作用。

首先,是的,我对 homedir 和 .ssh/* 的权限是正确的:

~$ ls -la .ssh
drwx------ 1 johndoe foo         5 10 apr 20:24 .
drwx------ 1 johndoe foo        50  8 aug 19:51 ..
-rw------- 1 johndoe foo      1617  7 aug 18:56 authorized_keys
-rw-r--r-- 1 johndoe foo       680 10 apr 20:24 config
-rw------- 1 johndoe foo      1675 17 dec  2018 id_rsa
-rw-r--r-- 1 johndoe foo       408 17 dec  2018 id_rsa.pub
-rw-r--r-- 1 johndoe foo      4050 10 apr 20:24 known_hosts

另外,似乎服务器上的每个用户都有这个问题,所以这些权限不应该是问题。

我检查的下一件事是ssh -vvv server。这显示了以下输出:

debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:SOMETHING /home/john/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/john/.ssh/id_dsa
debug3: no such identity: /home/john/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/john/.ssh/id_ecdsa
debug3: no such identity: /home/john/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/john/.ssh/id_ed25519
debug3: no such identity: /home/john/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

令我惊讶的是,它只提到尝试私钥id_dsa而不是id_rsa,但是在尝试连接到我没有复制密钥的服务器后,它看起来好像做了同样的事情。

我确实尝试再次使用 复制公钥ssh-copy-id server,它要求我提供密码,然后声称我应该尝试ssh server,但这仍然要求我提供密码。

在服务器端,我尝试检查是否有任何问题的迹象。因此,我尝试运行sudo journalctl -u sshd.service -f,它在尝试连接时给出以下输出,然后要求输入密码,并正确输入密码:

aug 08 20:42:13 server.domain.com sshd[30191]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=sshgateway.otherdomain.com  user=johndoe
aug 08 20:42:14 octiron.liacs.nl sshd[30191]: Accepted password for johndoe from 1.3.3.7 port 43636 ssh2

所以看起来尽管密钥是正确的,服务器仍然给出身份验证失败。

此时,我陷入了困境,试图寻找自己能做的事情。尝试连接 ssh 的详细输出清楚地列出了Authentications that can continue: publickey,因此我假设 pubkeys 会按照我期望的方式工作。权限都很好,但我仍然不知道如何让密钥正常工作。

我很感激任何尝试解决这个问题的提示。

编辑:当尝试对本地用户执行相同的操作时(使用本地磁盘上的 homedir,而不是 ceph 安装上的 homedir),这一切都按预期工作。

当尝试仅使用按键登录,然后按 ctrl+C 退出时,以下内容将添加到/var/log/secure

Aug  8 23:22:34 server sshd[16775]: Connection closed by 132.229.44.36 port 59610 [preauth]
Aug  8 23:22:51 server unix_chkpwd[16780]: password check failed for user (johndoe)
Aug  8 23:22:51 server sudo: pam_unix(sudo:auth): authentication failure; logname=johndoe uid=200104 euid=0 tty=/dev/pts/0 ruser=johndoe rhost=  user=johndoe
Aug  8 23:22:51 server sudo: johndoe : TTY=pts/0 ; PWD=/home/johndoe ; USER=root ; COMMAND=/bin/cat /var/log/secure
Aug  8 23:22:51 server sudo: pam_unix(sudo:session): session opened for user root by johndoe(uid=0)

答案1

在您的新测试中,您说在服务器上禁用 SELinux(setenforce 0或)会导致正常登录。您的 SELinux 设置对于已安装的文件系统和该用户来说可能是错误的。... permissivessh.ssh.ssh/*

请尝试以下操作:

restorecon -rv /home/*/.ssh

(或仅使用该一个用户)。

相关内容