【发布时间】:2012-02-20 05:41:09
【问题描述】:
我正在尝试配置一个 Hudson 作业以将 Hudson 作业的结果(由多个文件组成)复制到一个 Hudson 服务器中,以便从多个从属服务器进行结果整合。我的意图是使用 scp。不幸的是,我在 Windows 环境中设置 SSH 公钥/私钥有困难(从属服务器和 Hudson 服务器都是 Windows 环境)。我无法迁移到 Linux,因为我不是这些机器的所有者。
我使用以下过程来设置 SSH 公钥/私钥。
-
通过执行以下操作在 Hudson 机器中配置 ssh 服务器:
- cd C:\Program Files\OpenSSH\bin
- mkgroup -l >> ..\etc\group
- mkpasswd -l >> ..\etc\passwd
- mkpasswd -d -u test >> ..\etc\passwd(注意:test是SSH使用的用户ID)
- 从http://samanthahalfon.net/resources/cygwin_includes.zip 下载 cygintl-2.dll 和 cygwin1.dll。将这些 dll 文件复制到 C:\Program Files\OpenSSH\bin。 您需要替换 cygwin1.dll。
- cd C:\Program Files\OpenSSH\etc
- ..\bin\chown 测试 *
- ..\bin\chmod 600 *
- 使用以下配置编辑 C:\Program Files\OpenSSH\etc\sshd_config:
- 22 端口
- 协议 2
- 没有严格模式
- PubKeyAuthentication 是
- AuthorizedKeysFile /c/home/test/.ssh/authorized_keys
- 没有密码验证
- UserPrivilegeSeparation no
- 通过执行以下命令将其作为 Windows 服务启动:net start opensshd
-
在Hudson机器中配置ssh公钥,这样测试自动化脚本就不会提示输入密码了:
- 在从机中,使用“ssh-keygen -t dsa”命令创建密钥对。 默认情况下,密钥对(文件:id_dsa & id_dsa.pub)将生成到 C:\Documents and Settings\test.ssh\
- 使用“scp id_dsa.pub test@XX.XX.XX.XX:.ssh/id_rsa_upload.pub”命令上传公钥到Hudson Server。 即 scp id_dsa.pub test@XX.XX.XX.XX:.ssh/id_rsa_upload.pub
- 在 Hudson 服务器中,进入目录 C:\Program Files\OpenSSH.ssh,然后执行“type id_rsa_upload.pub >>authorized_keys”
- 通过执行“net stop opensshd”和“net start opensshd”退出并重新启动 Hudson 服务器上的 opensshd,您现在可以无需密码即可登录 ssh 服务器。
- 在 Hudson 服务器中,执行以下命令:
- cd C:\Program Files\OpenSSH\
- chown -R 测试。
- chmod -R 700 .ssh
- cd .ssh
- chmod 600 授权密钥
- 在从机中,编辑 C:\Program Files\OpenSSH\etc\ssh_config。指定“IdentityFile /c/home/test/id_dsa”。
-
从您的从属计算机测试哪个 SSH 私钥已被执行。在从机中,执行连接:
ssh test@XX.XX.XX.XX (IP是Hudson服务器的IP)
不幸的是,它仍然提示输入密码。
我研究了以下可能的解决方法,但结果并不乐观:
一个。 Hudson 服务器中的共享驱动器映射到从机中的驱动器 - Hudson 不允许“复制 result.html Y:”
b. sftp - 它还需要公钥
c。通过使用“copy result.html \XX.XX.XX.XX\test\”找到了解决共享驱动器问题的建议解决方案,但我遇到了访问被拒绝错误,因为我有 不知道如何使用此方法指定用户 ID 和密码。参考:Hudson continuous integration server: how to see Windows mapped directories that are visible to Ant?
d:我还研究了 Hudson 的插件以寻找任何潜在的解决方案,但找不到合适的或不知道插件的用法。
如果有人能发现我在公钥设置中的错误,或者为我提出一个替代解决方案来将多个文件复制到 Hudson 服务器,那就太好了。谢谢
【问题讨论】: