Windows 为Jenkins从属节点设置SSH凭据的推荐方法
问题陈述 我正在寻找一个关于在Jenkins主机和从机上设置SSH密钥以连接Git的正确方法的建议。关于Git、Jenkins和SSH(最接近的人),这里还有其他类似的问题,但似乎没有一个能回答这个问题并给出正确方法的具体建议 背景和测试 我正在使用内部GitLab开发Jenkins的原型实现。我们在Jenkins方面有几年的经验,但是将它与Git集成对我们来说是新的。这也是我们第一次配置任何从属节点。在这一点上,我们只是试图让简单的轮询工作,没有花哨的推送通知 主Jenkins实例正在Linux(6)上运行。目前有三个从服务器:另一个Red Hat Linux服务器和两个运行Windows server 2012 R2的服务器。Windows服务器上的Jenkins从属服务器作为Windows服务运行。主设备和所有从设备都运行最新的Git v2.10.0(64位) 我们打算使用SSH访问GitLab。我创建了一个带有密码短语的SSH密钥,并将其保存在主机上的磁盘上。然后,我在GitLab中将公钥配置为测试项目的部署密钥。最后,我在Jenkins中添加了一个新凭证 在Jenkins的第一个测试项目中,我配置了GitLab存储库URL并选择了上面创建的Jenkins凭据。然后我在大师的基础上建立了这个项目。Jenkins与GitLab的SSH连接没有问题,构建成功。然后,我强制将构建转移到Linux从机,得到了相同的结果 不幸的是,当强制将构建转移到任何一个Windows从机时,构建不像在Linux上那样工作 Windows上的错误 (根据我的原始问题编辑,基于进一步研究。) 我最初遇到这个错误,它阻止了任何SSH连接的发生:Windows 为Jenkins从属节点设置SSH凭据的推荐方法,windows,git,jenkins,ssh,Windows,Git,Jenkins,Ssh,问题陈述 我正在寻找一个关于在Jenkins主机和从机上设置SSH密钥以连接Git的正确方法的建议。关于Git、Jenkins和SSH(最接近的人),这里还有其他类似的问题,但似乎没有一个能回答这个问题并给出正确方法的具体建议 背景和测试 我正在使用内部GitLab开发Jenkins的原型实现。我们在Jenkins方面有几年的经验,但是将它与Git集成对我们来说是新的。这也是我们第一次配置任何从属节点。在这一点上,我们只是试图让简单的轮询工作,没有花哨的推送通知 主Jenkins实例正在Linu
stderr: Unable to negotiate with xxxx port 22: no matching host key type found. Their offer: ssh-dss
这与SSH级别的协商有关。与Git捆绑在一起的较新的SSH客户端在默认情况下不会使用SSH dss
,这就是我相对较旧的SSH服务器所能提供的全部功能
为了克服这个问题,我添加了包含以下行的%HOME%/.ssh/config
,正如OpenSSH在下面记录的那样:
这将强制Git SSH客户端接受SSH dss
连接
大约在同一时间,我还在为如何从与Git捆绑在一起的Windows SSH客户端获得详细的SSH输出而苦苦挣扎,因为通常的建议是设置Git\u SSH='SSH-vvv'
在Windows上不起作用。基于一个问题和一个类似的问题,我最终在%HOME%/.ssh/config
中得出了这个结论:
Host xxxx
HostKeyAlgorithms +ssh-dss
LogLevel DEBUG3
有了调试输出,我对正在发生的事情有了更好的了解。最后,我可以在Windows上成功构建,但前提是我使用的SSH密钥没有密码。提示出现在调试输出中:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password,hostbased
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: C:\\Users\\JENKIN~1.TMS\\AppData\\Local\\Temp\\ssh2489775972592020656key
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
由于某些原因,Jenkins无法在Windows上使用正确的密码短语设置SSH密钥,而在Linux上它可以正常工作。不幸的是,Jenkins没有从SSH转储调试输出,除非命令失败,所以我无法确切地看到Linux构建的不同之处
问题
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password,hostbased
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: C:\\Users\\JENKIN~1.TMS\\AppData\\Local\\Temp\\ssh2489775972592020656key
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method