我正在 Ubuntu 服务器中运行 Discourse 论坛软件容器,我能够使用该命令登录到容器。
sudo docker exec -it 应用程序 bash
然后我为 root 用户设置了密码,但是 ssh 没有按预期工作,总是得到错误的密码。
SSH 调试日志
Set /proc/self/oom_score_adj to 0
debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from ::1 port 45924 on ::1 port 22
debug1: Client protocol version 2.0; client software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: permanently_set_uid: 105/65534 [preauth]
debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: client->server aes128-ctr [email protected] none [preauth]
debug1: kex: server->client aes128-ctr [email protected] none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user root service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "root"
debug1: PAM: setting PAM_RHOST to "localhost"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user root service ssh-connection method password [preauth]
debug1: attempt 1 failures 0 [preauth]
pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=localhost user=root
debug1: PAM: password authentication failed for root: Authentication failure
Failed password for root from ::1 port 45924 ssh2
Excess permission or bad ownership on file /var/log/btmp
Connection closed by ::1 [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: PAM: cleanup
debug1: Killing privsep child 32712
请指教。
答案1
该问题现已解决。
似乎是 Discourse SSH 容器配置的问题,
在 /etc/ssh/sshd_config 中
PermitRootLogin without-password
我已将其更改为
PermitRootLogin yes
#PermitRootLogin without-password
这解决了问题。
答案2
您应该使用代码标记来粘贴到日志文件中,但据我所知:
sshd[32711]: debug1: PAM: password authentication
failed for root: Authentication failure Aug 26 20:32:29
似乎相关。您确定您的 docker 镜像的 root 用户使用了正确的密码吗?
另外,您是否重新启动了 sshd 服务(在 docker 映像中)以便重新加载 sshd_config ?