无法在 AWS EC2 Centos 7 VM 上运行 Jenkins Slave 作业

无法在 AWS EC2 Centos 7 VM 上运行 Jenkins Slave 作业

我的 Jenkins 主服务器在本地运行,我的从属服务器在 AWS 上运行。它是 Centos 7 EC2 虚拟机。

当 Jenkins 尝试通过 scp 推送 Slave.jar 文件时,它会失败并显示以下错误消息:

    java.io.IOException: Could not open channel (state:4)
    at com.trilead.ssh2.channel.ChannelManager.ioException(ChannelManager.java:1543)
    at com.trilead.ssh2.channel.ChannelManager.waitUntilChannelOpen(ChannelManager.java:122)
    at com.trilead.ssh2.channel.ChannelManager.openSessionChannel(ChannelManager.java:574)
    at com.trilead.ssh2.Session.<init>(Session.java:42)
    at com.trilead.ssh2.Connection.openSession(Connection.java:1145)
    at com.trilead.ssh2.SFTPv3Client.<init>(SFTPv3Client.java:99)
    at com.trilead.ssh2.SFTPv3Client.<init>(SFTPv3Client.java:119)
    at hudson.plugins.sshslaves.SFTPClient.<init>(SFTPClient.java:43)
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJar(SSHLauncher.java:1138)
    at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:148)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:833)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:810)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: The server refused to open the channel (SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, 'open failed')
    at com.trilead.ssh2.channel.Channel.setReasonClosed(Channel.java:331)
    at com.trilead.ssh2.channel.ChannelManager.msgChannelOpenFailure(ChannelManager.java:1392)
    at com.trilead.ssh2.channel.ChannelManager.handleMessage(ChannelManager.java:1484)
    at com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:809)
    at com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:502)
    ... 1 more
java.io.IOException: Could not copy slave.jar into '/home/nutanix' on slave
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJarUsingSCP(SSHLauncher.java:1222)
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJar(SSHLauncher.java:1183)
    at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:148)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:833)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:810)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Could not open channel (state:4)
    at com.trilead.ssh2.channel.ChannelManager.ioException(ChannelManager.java:1543)
    at com.trilead.ssh2.channel.ChannelManager.waitUntilChannelOpen(ChannelManager.java:122)
    at com.trilead.ssh2.channel.ChannelManager.openSessionChannel(ChannelManager.java:574)
    at com.trilead.ssh2.Session.<init>(Session.java:42)
    at com.trilead.ssh2.Connection.openSession(Connection.java:1145)
    at com.trilead.ssh2.Connection.exec(Connection.java:1566)
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJarUsingSCP(SSHLauncher.java:1216)
    ... 8 more
Caused by: java.io.IOException: The server refused to open the channel (SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, 'open failed')

中提供的解决方案SSH 隧道错误:“通道 1:打开失败:管理禁止:打开失败”不适合我。

答案1

您可以检查以下几项内容或尝试解决此问题:

  1. 检查 AWS 中的安全组,确保您的 Jenkins 服务器能够通过 SSH 访问任何从属服务器。我猜你已经准备好了,但值得检查一下。
  2. 登录 Jenkins 服务器并尝试直接从命令行连接到 Slaver 服务器。确保您能够以这种方式连接且没有错误。然后,确认您要连接的用户与 Jenkins 尝试使用的用户是同一用户。在您的输出中,我看到“无法将slave.jar复制到slave上的'/home/nutanix'”。在里面用于连接到 Linux 实例的 AWS 文档,CentOS系统的用户名是森托斯。确保 Jenkins 配置为使用该用户名,并且有权访问以该用户身份登录所需的密钥。
  3. 考虑使用亚马逊 EC2 插件用于连接到 AWS 中的从站。使用该插件,大部分设置都在配置中完成,您无需在作业级别担心它。此外,从站将根据需要上下旋转,从而保持较低的 AWS 成本。

相关内容