【发布时间】: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
等等等等
【问题讨论】: