简体   繁体   English

无法使用root用户连接到Jenkins从站

[英]Cannot Connect to Jenkins Slave using root user

I have a Jenkins master in the Windows server and using TFS as source control. 我在Windows服务器中有一个Jenkins主服务器,并使用TFS作为源代码管理。 I have connected few windows slave servers and a Linux slave server from my Jenkins master. 我从Jenkins主服务器连接了几个Windows从服务器和一个Linux从服务器。 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. 当我尝试使用“ root用户”使用“通过SSH在Unix计算机上启动从属代理”来配置Linux从属时,它会因抛出以下错误而无法连接。

[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. 密码是正确的,因为我可以使用与root用户相同的密码手动登录从服务器。 So I tried creating another user named "slave". 因此,我尝试创建另一个名为“奴隶”的用户。

Now Jenkins was able to connect to the slave server by using user slave. 现在,Jenkins能够使用用户slave连接到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. 但是在执行作业时,我正在运行一个shell脚本,该脚本用于手动运行,但出于CI的考虑,它应该从Jenkins运行,该脚本具有一些chown命令,但都失败了,并显示“ Permission被拒绝”错误,这很明显,因为我假设root用户只能运行chown命令。

So I edited /etc/passwd with slave:x:0:0:: to have root permissions. 所以我用slave:x:0:0 ::编辑了/ etc / passwd来拥有root权限。 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. 我已经接受了奴隶用户以及root用户的用户协议,但仍然收到此错误。

If I rollback the /etc/passwd script to run as slave user this error is gone but again I cant run chown command. 如果我回滚/ etc / passwd脚本以从用户身份运行,则此错误消失了,但再次无法运行chown命令。

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. 任何解决此问题的帮助将不胜感激,我可以使用root用户连接到slave,或者slave用户应执行chown命令。

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 ). 您有两个选择,要么必须启用root ssh访问(不建议),要么将您的“从属”用户添加到sudoers组并使用sudo运行chown命令(例如: sudo chown /path/to/file.txt )。

1) To enable root ssh access, edit /etc/ssh/sshd_config , and comment out the following line: 1)要启用root ssh访问,请编辑/etc/ssh/sshd_config ,并注释掉以下行:

PermitRootLogin without-password

Just below it, add the following line: 在它的下面,添加以下行:

PermitRootLogin yes

Then restart SSH: service ssh 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 2)要将用户添加到sudoers组,请按照以下链接中的说明进行操作: https : //access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/ch02s03.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM