Jenskins无法使用Shell脚本在另一个EC2实例上部署War文件

时间:2019-04-05 04:21:30

标签: amazon-web-services ubuntu jenkins amazon-ec2 jenkins-pipeline

我花了无数小时来完成这项琐碎的工作,但是它不会让步。我的目标是使用scp命令在MachineA上将Jenkins中编译的war文件部署到MachineB。但是我一直在遇到认证错误。

如果我手动将ssh放入MachineA并运行以下命令,则它可以正常运行:

scp -i ~/<keypairdemo.pem> <../*.war> ubuntu@<EC2-PRIVATE-IP>:~/apache-tomcat-8.5.39/webapps/

现在,如果我将确切的命令放在Jenkins的shell script选项中,它将继续引发以下错误。我尝试做chmod 777 dev/tty,但没有做任何事。我一直在修补自己甚至无法在自己的EC2实例上做sudo su的地步!

[WarFileDemo] $ /bin/sh /tmp/jenkins3925660300944070231.sh
“Starting to copy the build - aPPLY”
Executing: program /usr/bin/ssh host <EC2-PRIVATE-IP>, user ubuntu, command scp -v -t ~/apache-tomcat-8.5.39/webapps/
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to <EC2-PRIVATE-IP> [<EC2-PRIVATE-IP>] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /var/lib/jenkins/keypairdemo.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/lib/jenkins/keypairdemo.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.2
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to <EC2-PRIVATE-IP>: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: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Ee13H6eEq0VyQlVMUh2zIPyi/3eO5lMhpoALmCOZS/A
debug1: read_passphrase: can't open /dev/tty: No such device or address
Host key verification failed.
lost connection

我唯一能够部署的方法是使用Tomcat的deploy插件,为此我输入了tomcat服务器的凭据和URL。但是我想使用脚本来完成所有这些操作。

1 个答案:

答案 0 :(得分:0)

您似乎有一个主机密钥验证错误。

  

主机密钥验证失败。

尝试将-o StrictHostKeyChecking = no添加到您的scp命令中。