无法使用 root 用户连接到 Jenkins Slave

Cannot Connect to Jenkins Slave using root user

我在 Windows 服务器中有一个 Jenkins master 并使用 TFS 作为源代码控制。我已经连接了几个 windows 从服务器和一个 Linux 从我的 Jenkins 主服务器的从服务器。当我尝试使用 "Launch slave agents on Unix machines via SSH" 和 root 用户配置 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.call(SSHLauncher.java:701)
    at hudson.plugins.sshslaves.SSHLauncher.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.

密码是正确的,因为我可以使用与root用户相同的密码手动登录从服务器。所以我尝试创建另一个名为 "slave".

的用户

现在 Jenkins 可以使用用户 slave 连接到从服务器。但是在执行作业时,我正在 运行 宁一个 shell 脚本,我们用它来手动 运行 但为了 CI 它应该是 Jenkins 的 运行,该脚本有一些 chown 命令失败并出现 "Permission denied" 错误,这很明显,因为我认为 root 用户只能使用 运行 chown 命令。

所以我用 slave:x:0:0:: 编辑了 /etc/passwd 以获得 root 权限。 但知道作业因错误

而失败
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

我已经接受了从属用户和 root 用户的用户协议,但仍然出现此错误。

如果我将 /etc/passwd 脚本回滚到 运行 作为从属用户,这个错误就消失了,但我还是不能 运行 chown 命令。

任何解决此问题的帮助将不胜感激,要么我能够使用 root 用户连接到 slave,要么 slave 用户应该执行 chown 命令。

你有两个选择,要么必须启用 root ssh 访问(不推荐),要么将你的 "slave" 用户添加到 sudoers 组和 运行 使用 sudo 的 chown 命令(例如:sudo chown /path/to/file.txt).

1) 要启用 root ssh 访问,编辑 /etc/ssh/sshd_config,并注释掉以下行:

PermitRootLogin without-password

在其下方,添加以下行:

PermitRootLogin yes

然后重启SSH:service ssh restart

2) 要将用户添加到 sudoers 组,请按照 link 中的说明进行操作: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/ch02s03.html