简体   繁体   中英

Jenkins ssh to amazon ec2 instance

I am new to jenkins and want to ssh to amazon ec2 instance and perform some steps there. For now I am just trying to ssh to my amazon instance. I am using "Execute shell" to execute commands on EC2. No I have just put ssh ec2-user@ command. I don't understand where so I specify the ssh key to connect to the instance. Right now if I run the build I get the following error:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/LAD/workspace
[workspace] $ /bin/sh -xe /tmp/hudson4524738745485196769.sh
+ ssh -v ec2-user@<my ip address>
OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug1: Connecting to <my ip address> [<my ip address>] port 22.
debug1: Connection established.
debug1: identity file /var/lib/jenkins/.ssh/id_rsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_rsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_dsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ecdsa-cert type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ed25519 type -1
debug1: identity file /var/lib/jenkins/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 74:0d:73:17:f2:78:c4:51:e4:c4:55:8f:6d:94:9f:7a
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

How can I ssh into the ec2 instance from jenkins "Execute shell" section in the build? Please help on this.

您需要通过SSH进入jenkins主文件系统并将其放置在Jenkins盒子上,将SSH密钥本地放置在您的Jenkins盒子上。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM