AJN
AJN

Reputation: 347

Cannot Connect to Jenkins Slave using root user

I have a Jenkins master in the Windows server and using TFS as source control. I have connected few windows slave servers and a Linux slave server from my Jenkins master. When I try to configure Linux slave using "Launch slave agents on Unix machines via SSH"with root user, it fails to connect by throwing the below errors.

[SSH] Opening SSH connection to xxxxxx.
ERROR: Failed to authenticate as root. Wrong password. (credentialId:98262412-0d53-4f25-92de-beaa8458f459/method:password)
[08/21/15 04:01:43] [SSH] Authentication failed.
hudson.AbortException: Authentication failed.
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1178)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:701)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
[08/21/15 04:01:43] Launch failed - cleaning up connection
[08/21/15 04:01:43] [SSH] Connection closed.

The password is correct since I can login to the slave server manually using the same password as root user. So I tried creating another user named "slave".

Now Jenkins was able to connect to the slave server by using user slave. But while executing job I am running a shell script which we use to run manually but for the sake of CI it should be run from Jenkins, this script has some chown command which are failing with "Permission denied" error, which is obvious since I suppose root user can only run chown command.

So I edited /etc/passwd with slave:x:0:0:: to have root permissions. But know the job fails with the error

Error: You must accept the End User License Agreement for this product
Run 'tf eula' to accept the End User License Agreement.
FATAL: Executable returned an unexpected result code [100]
ERROR: null

I have already accepted user agreement for slave user and as well as root user but still getting this error.

If I rollback the /etc/passwd script to run as slave user this error is gone but again I cant run chown command.

Any help to resolve this will be appreciated, either I be able to connect to slave using root user or slave user should execute chown command.

Upvotes: 1

Views: 4541

Answers (1)

VDR
VDR

Reputation: 2853

You have two options, either you have to enable root ssh access(not recommended) or add your "slave" user to sudoers group and run chown command with sudo (eg: sudo chown /path/to/file.txt).

1) To enable root ssh access, edit /etc/ssh/sshd_config, and comment out the following line:

PermitRootLogin without-password

Just below it, add the following line:

PermitRootLogin yes

Then restart SSH: service ssh restart

2) To add a user to sudoers group, follow instructions as per this link: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/ch02s03.html

Upvotes: 2

Related Questions