I am trying to scp copy a jar file to AWS EC2 instance via Jenkins' job. The copy process fails with message "Host key verification failed"
The same command works fine for my colleague who uses the same pem key. I tried -v option and got the below message...
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ec2-3-x-54-111.us-east-2.compute.amazonaws.com [3.x.x.x] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/chetanapujar/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/zzz/.ssh/id_ed25519-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.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to ec2-2-z-54-x.us-east-2.compute.amazonaws.com:22 as 'ubuntu'
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: [email protected] MAC: compression: none
debug1: kex: client->server cipher: [email protected] MAC: compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:H--------
debug1: read_passphrase: can't open /dev/tty: Device not configured
Host key verification failed.
I renamed my "known_hosts" file (did not clear it or delete it) yet the same problem exists
Any help would be appreciated Thanks,
I used ssh command to get connected to AWS EC2 to test if pem file was valid. I was able to get connected successfully. I disconnected from SSH. After my first connection scp started working. I am not sure how my first SSH connection solved my problem of scp. I would appreciate if any one can explain.