Linux
SSH 到 docker 容器不工作
我在 Ubuntu 伺服器中執行一個 Discourse 論壇軟體容器,我能夠使用該命令登錄到容器。
sudo docker exec -it app 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 hmac-md5-etm@openssh.com none [preauth] debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com 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
請指教。
現在問題已解決。
似乎是 Discourse SSH 容器配置的問題,
在 /etc/ssh/sshd_config
PermitRootLogin without-password
我已將其更改為
PermitRootLogin yes
#PermitRootLogin without-password
這解決了這個問題。
您應該使用程式碼標記來粘貼日誌文件,但據我所知:
sshd[32711]: debug1: PAM: password authentication failed for root: Authentication failure Aug 26 20:32:29
似乎相關。你確定你為你的 docker 鏡像的 root 使用者使用了正確的密碼嗎?
另外,您是否重新啟動了 sshd 服務(在 docker 映像中)以便重新載入 sshd_config?