【问题标题】:Jenkins user ssh/config proxy not working, root user worksJenkins 用户 ssh/config 代理不工作,root 用户工作
【发布时间】:2017-10-05 11:33:14
【问题描述】:

我为 ssh 创建了一个代理设置,这样git clone 也为 SSH 使用 http 代理,当我在机器终端上以 root 身份运行它时,它可以工作。

但是,当我切换到 jenkins 用户时,我无法再通过代理 ssh 到 bitbucket。

当我使用 Jenkins 用户时,如何让 git 使用 ssh-trust(private-public key) 克隆 repo。

id_rsa 似乎按预期工作。来自 /var/lib/jenkins/.ssh

(同样,代理从命令行以 root 身份工作...)

设置代理

对于 root 和 jenkins,我在相应的主文件夹(/root 和 /var/lib/jenkins)中创建:

vi ~/.ssh/config

Host bitbucket.org
  HostName altssh.bitbucket.org
  Port 443
  ProxyCommand ncat --proxy webproxy.ec.local:9090 %h %p
  IdentityFile /var/lib/jenkins/.ssh/id_rsa

这是詹金斯使用尝试失败时的日志(我也尝试过提供-i /var/lib/jenkins/.ssh/id_rsa

另外:known_hosts 为空...

bash-4.2$ ssh bitbucket.org -v
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /var/lib/jenkins/.ssh/config
debug1: /var/lib/jenkins/.ssh/config line 1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Executing proxy command: exec ncat --proxy webproxy.ec.local:9090 altssh.bitbucket.org 443
debug1: permanently_drop_suid: 995

debug1: key_load_public: No such file or directory
debug1: identity file /var/lib/jenkins/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/lib/jenkins/.ssh/id_rsa-cert type -1

debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host

当我以 root 身份运行时,我得到(permanently_drop_suid: 995 的位置):

debug1: permanently_set_uid: 0/0
debug1: permanently_drop_suid: 0

本地版本字符串 SSH-2.0-OpenSSH_7.4

之后继续连接
debug1: Remote protocol version 2.0, remote software version conker_1.0.311-c6337e4 app-130
debug1: no match: conker_1.0.311-c6337e4 app-130
debug1: Authenticating to altssh.bitbucket.org:443 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32
debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

等等等等

【问题讨论】:

    标签: linux git ssh proxy


    【解决方案1】:

    我遇到了一个稍微类似的问题。通过将 .ssh/config 从 /root/.ssh 复制到 $JENKINS_HOME/.ssh/config

    ,我能够让我的 jenkins 工作(虽然不是闲置的)

    【讨论】:

      【解决方案2】:

      我怀疑问题出在这里:

        ProxyCommand ncat --proxy webproxy.ec.local:9090 %h %p
      

      Netcat 尝试以普通用户身份绑定到端口,但失败了。如果可能,尝试将绑定端口更改为大于 1024。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-02
        • 2023-03-06
        • 1970-01-01
        • 1970-01-01
        • 2019-04-28
        • 2020-05-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多