简体   繁体   English

将Mac Hudson从属连接到Linux主服务器时,SSH密钥身份验证失败

[英]SSH Key authentication failing when connecting Mac Hudson slave to Linux master

Ok, so I have Hudson (v1.393) running in an Ubuntu VM and everything's working fine. 好吧,所以我让Hudson(v1.393)在Ubuntu VM中运行,一切正常。 However I'm trying to add a Mac slave to the Ubuntu master and I've run in to a few problems. 但是我正在尝试将一个Mac奴隶添加到Ubuntu主服务器中,我遇到了一些问题。

I have set up SSH keys so that from the command line, the Ubuntu VM can ssh using the key into a user called hudson on the Mac. 我已经设置了SSH密钥,因此从命令行,Ubuntu VM可以使用密钥ssh到Mac上的一个名为hudson的用户。

In the Hudson slave configuration, I have "Launch slave agents on Unix machines via SSH" selected and have entered the host IP, username of the user on the slave and the location of my private key file on the master (which has been added to the authorised keys file on the slave). 在Hudson slave配置中,我选择了“通过SSH在Unix机器上启动从属代理”并输入了主机IP,从属用户的用户名以及我的私钥文件在主服务器上的位置(已添加到主服务器)奴隶上的授权密钥文件)。

However, the master fails to connect to the slave. 但是,主站无法连接到从站。 Looking at the log (below), it's trying to authenticate using a password. 查看日志(下面),它正在尝试使用密码进行身份验证。

Is this a fall back for a failed key based SSH attempt? 这是基于密钥的SSH尝试失败的后退吗?
Is Hudson only trying to authenticate using a password, and I need to change something else to get it to use the key file which is defined in the configuration? Hudson是否只尝试使用密码进行身份验证,我需要更改其他内容以使其使用配置中定义的密钥文件?
Is it just not possible to launch slave agents via ssh on a mac? 是不是可以通过mac上的ssh启动slave代理? (I know the name of this type of slave launch method explicity states Unix, but I was thinking (read: hoping) that it would work with OS X too) (我知道这种类型的奴隶启动方法明确表示Unix的名称,但我正在考虑(阅读:希望)它也适用于OS X)

Log 日志

[01/14/11 10:38:07] [SSH] Opening SSH connection to 10.0.1.188:22.
[01/14/11 10:38:07] [SSH] Authenticating as hudson/******.
java.io.IOException: Password authentication failed.
at com.trilead.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:319)
at com.trilead.ssh2.Connection.authenticateWithPassword(Connection.java:314)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:565)
at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:179)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:184)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.io.IOException: Authentication method password not supported by the server at this stage.
at com.trilead.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:289)
... 9 more
[01/14/11 10:38:07] [SSH] Connection closed.

If anyone has managed to conquer this type of set up before, or has any tips or ideas, I'd be very grateful! 如果有人设法征服过这种类型的设置,或者有任何提示或想法,我将非常感激! Thanks 谢谢

I've recently run into the same problem, trying to launch an agent on a Mac OS X 10.6 machine using SSH. 我最近遇到了同样的问题,尝试使用SSH在Mac OS X 10.6机器上启动代理。

To get password authentication to work you'll need to edit /etc/sshd_config on the client node, setting PasswordAuthentication yes 要使密码验证工作,您需要在客户端节点上编辑/ etc / sshd_config,设置PasswordAuthentication yes

In the Hudson dashboard take the node offline, make sure the configuration has a valid username and password, and launch the agent. 在Hudson仪表板中,使节点脱机,确保配置具有有效的用户名和密码,然后启动代理。 Also make sure that the Remote FS root directory is owned by the build user you're connecting as. 还要确保远程FS根目录由您正在连接的构建用户拥有。

For password-less ssh authentication, first check which user the Hudson master is running as. 对于无密码的ssh身份验证,首先要检查Hudson主服务器正在运行的用户。 Lets assume that this is tomcat55 . 让我们假设这是tomcat55 Generate a public/private SSH key pair (with an empty passphrase), then verify that the Hudson user can connect. 生成公钥/私钥SSH密钥对(使用空密码),然后验证Hudson用户是否可以连接。

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tomcat55/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/tomcat55/.ssh/id_rsa.
Your public key has been saved in /home/tomcat55/.ssh/id_rsa.pub.

$ # authorize the hudson master on the hudson node
$ scp /home/tomcat55/.ssh/id_rsa.pub hudson@macnode:~/.ssh/authorized_keys
$ # test the connection
$ ssh -i /home/tomcat55/.ssh/id_rsa hudson@macnode

On the Hudson mac node, the /etc/sshd_config needs to allow for password-less access. 在Hudson mac节点上,/ etc / sshd_config需要允许无密码访问。

Protocol 2
PubkeyAuthentication yes

In the node configuration clear the password field, and set the private key field (in this example it is /home/tomcat55/.ssh/id_rsa). 在节点配置中清除密码字段,并设置私钥字段(在此示例中为/home/tomcat55/.ssh/id_rsa)。 You should now be able to launch the agent: 您现在应该能够启动代理:

[01/19/11 22:38:44] [SSH] Opening SSH connection to macnode:22.
[01/19/11 22:38:44] [SSH] Authenticating as hudson with /home/tomcat55/.ssh/id_rsa.
[01/19/11 22:38:45] [SSH] Authentication successful.

Check the /var/log/auth.log file on the Ubuntu machine. 检查Ubuntu机器上的/var/log/auth.log文件。 I'm betting you need to chmod 700 the .ssh directory of the hudson user. 我打赌你需要chmod 700 hudson用户的.ssh目录。

I think the first answer (the selected one) is an awesome answer, but I did find a case where it is not the only solution. 我认为第一个答案(选择的答案)是一个很棒的答案,但我确实找到了一个不是唯一解决方案的案例。

In my case I have a Mac OS slave that was working and then I took that Mac down and brought up a new one. 在我的情况下,我有一个Mac OS奴隶正在工作,然后我拿下那台Mac,并提出了一个新的。 I thought I could just tweak the settings for the existing node's configuration to point it at the new Mac. 我想我可以调整现有节点配置的设置,将其指向新的Mac。 It didn't work and I had all the same errors and problems described throughout this message thread. 它没有用,我在整个消息线程中描述了所有相同的错误和问题。

Then I went in and deleted the node and recreated it with exactly the same settings and it worked. 然后我进入并删除了节点并使用完全相同的设置重新创建它并且它工作。 I suspect that SSH key fingerprint changed and by deleting the node and recreating it I was able to get it working. 怀疑 SSH密钥指纹已更改,通过删除节点并重新创建它,我能够使其正常工作。 Whatever it is, the key component that caused it to fail is not a configuration option. 无论是什么,导致它失败的关键组件都不是配置选项。

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

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