在 Jenkins 管道下运行的 SCP 命令无法连接

时间:2021-01-26 09:05:48

标签: jenkins ssh

我正在尝试将 scp 副本从另一台服务器复制到我的 Jenkins 工作区,但它不起作用。通常错误是说找不到 ssh-askpass。但是,我从未在管道中指定 askpass。我的错误如下。请注意,为了增加匿名性,我更改了报告日志中的用户 ID 和主机;如果有人能够以某种方式对哈希进行逆向工程,我会提到这一点。

我(努力)验证了传入的文件的值,并将私钥传递到对 scp 的调用中。我可以在本地机器上手动复制。

.section-wrap img {
  display: inline-block;
  float: left;
  border: 0; 
}

管道片段:

[Pipeline] sh
+ scp -i **** -v 'myuser@mycompany.com:/ic2e/SSCSetup/SSCFiles/SSC*.CP037' host-dirs/cost-files
Executing: program /usr/bin/ssh host mycompany.com, user myuser, command scp -v -f /ic2e/SSCSetup/SSCFiles/SSC*.CP037
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to mycompany.com [xx.xxx.60.206] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file **** type -1
debug1: key_load_public: No such file or directory
debug1: identity file ****-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to mycompany.com:22 as 'myuser'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-64@openssh.com compression: none
debug1: kex: curve25519-sha256 need=16 dh_need=16
debug1: kex: curve25519-sha256 need=16 dh_need=16
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:M9+dnJIbV51qw3YyJ11k4+A4W65gBvbg+/FG4uC8q7s
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: permanently_drop_suid: 1019
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Host key verification failed.
[Pipeline] }

1 个答案:

答案 0 :(得分:1)

您可以禁用主机密钥验证并重试。有一个属性 -o StrictHostKeyChecking=no