启了个 docker 容器, 开启了 ssh 登录,过一天后重新登录,密码不对是咋回事

2021-06-02 15:49:52 +08:00
 css3

docker build 的镜像,ssh 的密码在 build 的时候设置的,非常奇怪是的,容器启动后,正常可以用 ssh 登录,但过一天后,新开窗口重新 ssh 登录,密码就不对了,而且昨天开的已登录窗口还能正常使用。 重启 docke 容器后,又能正常登录,是啥原因啊? 没有人改密码啊,好几天都是这样,都是通过重启容器来解决,不清楚原因是啥

1641 次点击
所在节点    Docker
11 条回复
maichael
2021-06-02 16:12:27 +08:00
"重启 docker 容器后,又能正常登录",因为 Docker 是无状态的,重启之后会回归刚开始的状态。所以应该是你容器内的某个设置会进行更改密码,可以给下 Dockerfile 关键信息吗
css3
2021-06-02 18:59:25 +08:00
@maichael 贴上了 Dockerfile
PbCopy111
2021-06-02 20:33:36 +08:00
这。。。不是每次生成新密码么。。。。。
css3
2021-06-02 22:14:29 +08:00
@PbCopy111 build 指定的
killva4624
2021-06-03 10:44:21 +08:00
1 、ssh 的时候具体报错是什么?(可以用 -v 打印出来)
2 、“重启容器”的具体操作是什么? docker restart xxx 吗,还是每次都重新 build ?看 Dockerfile,如果不重新 build 的话,这个 image 的 sshpassword 是不会变的。
css3
2021-06-03 12:03:00 +08:00
@killva4624 隔天 ssh 登录就是提示密码不正确
css3
2021-06-03 12:03:49 +08:00
@killva4624 肯定不是 build 啊,直接 restart,或者直接 run
css3
2021-06-03 13:06:02 +08:00
@killva4624 Permission denied, please try again.
css3
2021-06-03 13:09:49 +08:00
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.12.44 [192.168.12.44] port 23.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.10
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.10 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.12.44:23 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:jI6QVVi6Qmi5oZvugssXrHN4Qxjrw9BDNoowxaIZ7so
debug1: Host '[192.168.12.44]:23' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
root@192.168.12.44's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
root@192.168.12.44's password:
julyclyde
2021-06-03 16:24:14 +08:00
docker exec 进去看看 sshd 的日志吧
killva4624
2021-06-04 10:22:53 +08:00
@css3 出 Permission denied 的时候,docker exec 进去看看你的 /etc/ssh/sshd_config,还有 sshd 的日志。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/780892

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX