dildeepak
dildeepak

Reputation: 1389

Could not copy slave.jar into '/home/jenkins' on slave

My existing jenkins master-slave connection got broken . I tried establishing the connection via scp command.

On master:

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

On slave :

•   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

After trying to connect from UI, getting the below error.

[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.

I have even tried the below posts, but did not get the resolution.

Upvotes: 8

Views: 25124

Answers (8)

Raheel Rao
Raheel Rao

Reputation: 31

This solved my issue after upgrading the plugin to 1.32.0

https://issues.jenkins.io/browse/JENKINS-67258

"Please note, apparently upgrading SSH Build Agents / SSH Slaves Plugin to version 1.32.0 and beyond helps with resolving this problem."

Upvotes: 0

Over_support
Over_support

Reputation: 1

current login user Directory ownership provide user jenkins login same directory ownership set

sudo chown jenkins:jenkins /opt/jenkins
sudo chmod 755 /opt/jenkins

Upvotes: -3

user2310395
user2310395

Reputation: 307

https://issues.jenkins.io/browse/JENKINS-67258

"Please note, apparently upgrading SSH Build Agents / SSH Slaves Plugin to version 1.32.0 and beyond helps with resolving this problem."

Upvotes: 1

Akhil J
Akhil J

Reputation: 31

I was having this error. I removed the existing remote.jar in the remote server and try to recreate the agent. It went well now

Upvotes: 3

twasbrillig
twasbrillig

Reputation: 18821

I was having this error, and I tried the above solutions, but the only way I was able to resolve it was by deleting the node, deleting the /opt/jenkins folder, and recreating the folder and the node. After that it worked fine.

Upvotes: 0

Amit Ganvir
Amit Ganvir

Reputation: 21

Like if you have a username "jenkins" and home dir is "/home/jenkins" You have to put this home directory in your node configuration, see "Remote root directory: /home/jenkins" It resolved my issue.. especially for AWS-ec2 and dont set full permission on home directory, it will affect it.

Upvotes: 1

Andrey
Andrey

Reputation: 1616

sudo chmod -R 777 /home/jenkins

Upvotes: -4

Kenster
Kenster

Reputation: 25380

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.)

It looks like you're connecting to this server as a user named "dx00926". The simplest explanation for this error is that this "dx00926" user on the remote system doesn't have permission to create files in the directory /home/jenkins, or there's an existing file named "/home/jenkins/slave.jar" there and this user doesn't have permission to overwrite its contents.

Either modify the permission on the /home/jenkins directory to permit dx00926 to create files there, or connect to the remote system with a user that does have permissions to create files there.

Upvotes: 7

Related Questions