I'm trying to do an scp copy from another server to a my Jenkins workspace, but it's not working. Usually the error is says ssh-askpass cannot be found. However, I never specified askpass in the pipeline. My error is below. Please note I changed the userid and host in the reported log for increased anonymity; I mention this in case someone is somehow able to reverse engineer the hash.
I (with effort) verified the value of the file being passed in and am passing in a private key into the call to scp. I can do the same copy by hand in my local machine.
[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] }
Snippet of pipeline:
stage('Copy Cost File To Jenkins'){
withCredentials([sshUserPrivateKey(credentialsId: "462e5c76-fae2-4d66-a72b-15ddba9dc785", keyFileVariable: 'my_private_key_file')]) {
sh "scp -i ${my_private_key_file} -v myuser@mycompany.com:/some_path/SSC*.CP037 host-dirs/cost-files"
}
}
question from:
https://stackoverflow.com/questions/65898483/scp-command-running-under-jenkins-pipeline-does-not-connect 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…