连接到Jenkins中的Git存储库

时间:2018-08-17 15:18:28

标签: git jenkins ssh

我在连接到Jenkins中的git存储库时遇到了一个实际问题。我正在使用Jenkins 2.121.3,该版本已从Jenkins主服务器上的〜/ .ssh /目录中删除了使用密钥的功能。

我已经生成了一个私钥/公钥对,并将密钥内容添加到Jenkins凭证中。我已将所需用户的公钥上传到我们的BitBucket服务器。

登录到Jenkins master,我可以成功连接并克隆存储库

sudo su - jenkins -s /bin/bash
git clone ssh://git@git.ourbitbucketserver/group/repo.git

但是,每当我尝试在Jenkins中设置git插件时,都会出现以下错误

Failed to connect to repository : Command "git ls-remote -h 
ssh://git@git.ourbitbucketserver/group/repo.git HEAD" returned status code 128:
stdout: 
stderr: ssh_exchange_identification: Connection closed by remote host 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我们有一个不同的Jenkins实例在较旧的版本上运行,该实例使我们能够从Jenkins主服务器加载密钥,并且这毫无问题地连接到同一服务器,因此我认为与配置无关的Git服务器,并且如果我们通过SSH到Jenkins主服务器,我们可以成功克隆存储库,那么我就不会认为这是密钥对的问题。

还有其他人在直接输入私钥时遇到问题吗?

0 个答案:

没有答案