gpt4 book ai didi

docker - 从Jenkins Docker容器通过SSH进入远程主机

转载 作者:行者123 更新时间:2023-12-02 19:45:15 25 4
gpt4 key购买 nike

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

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

  • 以下是 Debug模式的输出-
    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

    关于docker - 从Jenkins Docker容器通过SSH进入远程主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63888819/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com