2016-01-21 308 views
0

我是jenkins的新手,想要ssh到amazon ec2实例并在那里执行一些步骤。现在我只是试图ssh到我的亚马逊实例。我正在使用“Execute shell”在EC2上执行命令。不,我刚刚把ssh ec2-user @命令。我不明白在哪里,所以我指定的SSH密钥连接到实例。现在如果我运行生成我得到以下错误:Jenkins ssh到amazon ec2实例

Started by user anonymous 
Building in workspace /var/lib/jenkins/jobs/LAD/workspace 
[workspace] $ /bin/sh -xe /tmp/hudson4524738745485196769.sh 
+ ssh -v [email protected]<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 [email protected] none 
debug1: kex: client->server aes128-ctr [email protected] none 
debug1: kex: [email protected] need=16 dh_need=16 
debug1: kex: [email protected] 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 

我怎样才能ssh到从詹金斯的EC2实例在构建“执行shell”部分?请帮助。

+0

如果你想通过ssh在远程机器上运行shell命令,你可以使用SSH插件https://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin希望它有帮助 –

+0

嗨@HussainZKathawala我已经添加了ssh插件。我去管理詹金斯 - >配置系统 - > SSH远程主机 - >添加。 它问我一个密钥文件路径?我在我的实例上生成了一个公钥,但它如何在jenkins仪表板上提供它。没有选择上传甚至粘贴关键内容。 –

+1

您可以使用PublishOverSSHPlugin它完美地工作。 https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+SSH+Plugin –

回答

1

您需要在您的Jenkins盒上本地SSH密钥,方法是将SSH密钥放入jenkins主文件系统并放置在那里。