【问题标题】:Cannot Connect to Jenkins Slave using root user无法使用 root 用户连接到 Jenkins Slave
【发布时间】:2015-08-21 20:28:33
【问题描述】:

我在 Windows 服务器中有一个 Jenkins master,并使用 TFS 作为源代码控制。我已经从我的 Jenkins 主服务器连接了几个 Windows 从服务器和一个 Linux 从服务器。当我尝试使用 root 用户使用“在 Unix 机器上通过 SSH 启动从代理”配置 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.

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

现在 Jenkins 可以使用用户 slave 连接到从服务器。但是在执行作业时,我正在运行一个我们用来手动运行的 shell 脚本,但为了 CI 它应该从 Jenkins 运行,这个脚本有一些 chown 命令失败,出现“权限被拒绝”错误,这很明显,因为我假设 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 用户连接到从站,或者从站用户应该执行 chown 命令。

【问题讨论】:

  • 您输入的用户名是否正确?
  • 是的用户名是正确的

标签: linux jenkins ssh continuous-integration master-slave


【解决方案1】:

您有两个选择,要么您必须启用 root ssh 访问(不推荐),要么将您的“奴隶”用户添加到 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 组,请按照此链接的说明进行操作: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/ch02s03.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    相关资源
    最近更新 更多