繁体   English   中英

从 Jenkins docker 容器 SSH 到远程主机

[英]SSH into remote host from Jenkins docker container

我正在运行 docker 容器,作为一项工作的一部分,我必须通过 ssh 进入远程主机并在远程主机中执行一些命令。 我正在遵循以下方法。

  1. 启动 Jenkins 容器并且运行良好
  2. 检查我是否能够 ping 远程实例并且它工作正常。 我也可以使用密码进行 ssh。
  3. 现在我已经在docker容器中生成了公钥和私钥,并将公钥推送到远程主机的authorized_keys中。
  4. 当我尝试执行无密码 SSH 时,它将使用密码方法。

以下是调试模式的输出 -

debug1: rekey after 134217728 blocks
debug2: key: /var/jenkins_home/.ssh/id_rsa (0x56281fc480e0)
debug2: key: /var/jenkins_home/.ssh/id_dsa ((nil))
debug2: key: /var/jenkins_home/.ssh/id_ecdsa ((nil))
debug2: key: /var/jenkins_home/.ssh/id_ed25519 ((nil))
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /var/jenkins_home/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /var/jenkins_home/.ssh/id_dsa
debug1: Trying private key: /var/jenkins_home/.ssh/id_ecdsa
debug1: Trying private key: /var/jenkins_home/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: Next authentication method: password

不确定我缺少什么,因为我在从 docker 主机到远程机器执行无密码 SSH 时遵循完全相同的方法,并且它工作正常。

任何帮助表示赞赏,非常感谢。

解决了这个问题。 为 sshd 启用日志记录,并在 /var/log/messages 中发现主文件夹权限错误的错误。

以下两个链接有助于解决-

https://www.howtogeek.com/168156/fixing-authentication-refused-bad-ownership-or-modes-for-directory/

https://security.stackexchange.com/questions/152594/understanding-the-offering-rsa-public-key-step-during-ssh-connection-initializ

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM