代码之家  ›  专栏  ›  技术社区  ›  devyJava

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

  •  0
  • devyJava  · 技术社区  · 7 年前

    我花了无数的时间来做这些琐碎的工作,但它不会改变。我的目标是使用 scp 命令。但它总是有身份验证错误。

    如果我手动ssh到MachineA并运行以下命令,它会正常工作:

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

    现在,如果我把这个命令放在 shell script 在詹金斯的选项中,它继续抛出以下错误。我试过了 chmod 777 dev/tty ,它什么也没做。我一直在修修补补到连我都做不到的地步 sudo su 现在是我自己的EC2实例!

    [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的部署插件,我已经为它输入了Tomcat服务器的凭据和URL。但我想用脚本来完成这一切。

    0 回复  |  直到 7 年前
        1
  •  0
  •   Rodrigo Murillo    7 年前

    似乎存在主机密钥验证错误。

    主机密钥验证失败。

    尝试在scp命令中添加-o StrictHostKeyChecking=no。