【问题标题】:SSH into remote host from Jenkins docker container从 Jenkins docker 容器 SSH 到远程主机
【发布时间】:2020-09-15 14:42:14
【问题描述】:

我正在运行 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 时遵循完全相同的方法,并且工作正常。

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

【问题讨论】:

  • 您确定服务器支持 RSA 密钥吗?
  • 如果您在谈论 Docker 主机或远程服务器,请告诉我,仅供参考,我可以在 Docker 主机和远程服务器之间进行无密码 ssh。

标签: docker


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2016-03-19
    • 2021-10-25
    • 2020-10-22
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多