【问题标题】:Could not copy slave.jar into '/home/jenkins' on slave无法将 slave.jar 复制到 slave 上的“/home/jenkins”
【发布时间】:2017-04-19 21:34:38
【问题描述】:

我现有的詹金斯主从连接坏了。我尝试通过 scp 命令建立连接。

在主人身上:

scp ~/ .ssh/id_rsa.pub jenkins@<my_slave_machine>:/tmp

在奴隶上:

•   ssh-keygen –b 2048 –t rsa
•   Press enter for " Enter file in which to save the key (/home/jenkins/.ssh/id_rsa) : " 
•   Press enter for  " Enter passphrase (empty for no passphrase):" 
•   Press enter for  " Enter same passphrase again:"
•   cd .ssh/
•   touch authorized_keys
•   chmod 600 authorized_keys
•   cat /tmp/id_rsa.pub >> authorized_keys

尝试从 UI 连接后,出现以下错误。

[12/05/16 07:53:48] [SSH] Opening SSH connection to <my_slave_machine>:22.
[12/05/16 07:53:49] [SSH] Authentication successful.
[12/05/16 07:53:49] [SSH] The remote users environment is:
ENV=/home/dx00926/.kshrc
FACTERLIB=/var/lib/puppet/rel_RHEL6_64_670/lib/facter
FCEDIT=ed
HISTCMD=0
HOME=/home/dx00926
IFS=$' \t\n'
JOBMAX=0
KSH_VERSION=.sh.version
LINENO=1
LOGNAME=dx00926
MAIL=/var/mail/dx00926
MAILCHECK=600
OPTIND=1
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/adnssh/bin
PPID=1455663
PS2='> '
PS3='#? '
PS4='+ '
PWD=/home/dx00926
RANDOM=6009
SECONDS=0.000
SFTP_PERMIT_CHMOD=1
SFTP_PERMIT_CHOWN=1
SFTP_UMASK=''
SHELL=/bin/ksh
SHLVL=1
SSH_CLIENT='148.112.120.212 35609 22'
SSH_CONNECTION='148.112.120.212 35609 10.33.70.153 22'
TMOUT=0
USER=dx00926
[12/05/16 07:53:49] [SSH] Starting sftp client.
[12/05/16 07:53:49] [SSH] Copying latest slave.jar...
hudson.util.IOException2: Could not copy slave.jar into '/home/jenkins' on slave
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJar(SSHLauncher.java:1054)
    at hudson.plugins.sshslaves.SSHLauncher.access$300(SSHLauncher.java:137)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:723)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:706)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: hudson.util.IOException2: Could not copy slave.jar to '/home/jenkins/slave.jar' on slave
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJar(SSHLauncher.java:1049)
    ... 7 more
Caused by: com.trilead.ssh2.SFTPException: Permission denied (SSH_FX_PERMISSION_DENIED: The user does not have sufficient permissions to perform the operation.)
    at com.trilead.ssh2.SFTPv3Client.openFile(SFTPv3Client.java:1201)
    at com.trilead.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1074)
    at com.trilead.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1055)
    at hudson.plugins.sshslaves.SFTPClient.writeToFile(SFTPClient.java:93)
    at hudson.plugins.sshslaves.SSHLauncher.copySlaveJar(SSHLauncher.java:1039)
    ... 7 more
[12/05/16 07:53:49] Launch failed - cleaning up connection
[12/05/16 07:53:49] [SSH] Connection closed.

我什至尝试了以下帖子,但没有得到解决方案。

【问题讨论】:

    标签: linux jenkins ssh ssh-keys


    【解决方案1】:
    ENV=/home/dx00926/.kshrc
    ...
    HOME=/home/dx00926
    ...
    USER=dx00926
    

    ...
    hudson.util.IOException2: Could not copy slave.jar into '/home/jenkins' on slave
    ...
    Caused by: com.trilead.ssh2.SFTPException: Permission denied (SSH_FX_PERMISSION_DENIED: The user does not have sufficient permissions to perform the operation.)
    

    您似乎以名为“dx00926”的用户身份连接到此服务器。这个错误最简单的解释是远程系统上的这个“dx00926”用户没有在/home/jenkins目录下创建文件的权限,或者那里有一个名为“/home/jenkins/slave.jar”的文件并且此用户无权覆盖其内容。

    要么修改 /home/jenkins 目录的权限以允许 dx00926 在那里创建文件,要么使用 确实 有权在那里创建文件的用户连接到远程系统。

    【讨论】:

    • 感谢您的精彩解释。我通过管理员权限登录并解决了问题。一旦我们理解了问题陈述,解决方案就变得如此简单。再次感谢。
    【解决方案2】:

    如果你有一个用户名“jenkins”并且主目录是“/home/jenkins” 您必须将此主目录放在节点配置中,请参阅“远程根目录:/home/jenkins” 它解决了我的问题.. 特别是对于 AWS-ec2 并且不要对主目录设置完全权限,它会影响它。

    【讨论】:

      【解决方案3】:

      我遇到了这个错误,我尝试了上述解决方案,但我能够解决它的唯一方法是删除节点,删除 /opt/jenkins 文件夹,然后重新创建文件夹和节点。之后它工作正常。

      【讨论】:

        【解决方案4】:

        sudo chmod -R 777 /home/jenkins

        【讨论】:

        • 这绝不是正确的答案。
        猜你喜欢
        • 1970-01-01
        • 2015-04-30
        • 1970-01-01
        • 1970-01-01
        • 2013-06-30
        • 1970-01-01
        • 2017-03-24
        • 2017-06-04
        • 1970-01-01
        相关资源
        最近更新 更多