改为 jenkins 用户并手动运行命令:
jenkins
git ls-remote -h git@bitbucket.org:person/projectmarket.git HEAD
首次通过SSH连接到新主机时,您将收到标准的SSH警告:
The authenticity of host 'bitbucket.org (207.223.240.181)' can't be established. RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)?
类型 yes 然后按Enter键。主机密钥 bitbucket.org 现在将添加到 ~/.ssh/known_hosts 文件,你不会再在詹金斯得到这个错误。
yes
bitbucket.org
~/.ssh/known_hosts
有同样的问题,我修复它:
id_rsa *的重置权限仅适用于当前用户没有其他组
chmod o-rwx ~/.ssh/id* chmod G-rwx ~/.ssh/id* ls -lart ~/.ssh/ -rw------- 1 jenkins nogroup 398 avril 3 09:34 id_rsa.pub -rw------- 1 jenkins nogroup 1675 avril 3 09:34 id_rsa
并清除〜/ .ssh / know_hosts
现在连接詹金斯
sudo su jenkins
试试jenkins命令
git ls-remote -h git@bitbucket.org:user/project.git HEAD
如果没有问题,现在jenkins将能够连接回购(至少对我来说^^)
从bitbucket和github复制主机密钥:
ssh root @ deployserver'echo“$(ssh-keyscan -t rsa,dsa bitbucket.org)”>> /root/.ssh/known_hosts' ssh root @ deployserver'echo“$(ssh-keyscan -t rsa,dsa github.com)”>> /root/.ssh/known_hosts'
Jenkins是一个服务帐户,它没有设计shell。通常接受服务帐户。不应该以交互方式登录。
要解决“Jenkins主机密钥验证失败”,请执行以下步骤。我和詹金斯一起使用了mercurial。
1)在终端上执行以下命令
$ sudo su -s /bin/bash jenkins
提供密码
2)使用以下命令生成公钥:
ssh-keygen
你可以看到输出::
Generating public/private rsa key pair. Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again:
3)按Enter键 - >不要给任何密码短语 - >按回车键
Key has been generated
4)转到 - > cat /var/lib/jenkins/.ssh/id_rsa.pub
5)从id_rsa.pub复制密钥
6)退出bash
7) ssh@yourrepository
ssh@yourrepository
8) vi .ssh/authorized_keys
vi .ssh/authorized_keys
9)粘贴密钥
10)退出
11)手动登录mercurial服务器
注意:请手动登录,否则jenkins将再次给出错误“主机验证失败”
12)一旦手动完成,现在去Jenkins并进行构建
请享用!!!
祝好运
尝试
ssh-keygen -R主机名
-R hostname从known_hosts文件中删除属于hostname的所有密钥。此选项对于删除散列主机很有用
期运用 https://bitbucket.org/YYYY/XX.git
你shoud删除用户名@
最好的方法是在Jenkins文件中或任何你想要的地方使用“https”URL格式的“git url”。
git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
我遇到了这个问题,原来问题是jenkins服务没有作为jenkins用户运行。所以像jenkins用户一样运行命令就可以了。
而已!
你现在可以重新开始jenkins的工作了。
我希望你能解决这个问题。
确保我们没有编辑任何默认的sshd_config属性来跳过错误
主机验证失败 - 绝对是主机名的缺失条目 known_hosts 文件
known_hosts
登录进程失败的服务器并执行以下操作:
Sudo给用户运行进程
ssh-copy-id destinationuser@destinationhostname
它会第一次这样提示,说是,它也会第一次询问密码:
The authenticity of host 'sample.org (205.214.640.91)' can't be established. RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)? *yes*
密码提示? 给密码
现在,从运行进程的服务器,执行 ssh destinationuser@destinationhostname 。它应该没有密码登录。
ssh destinationuser@destinationhostname
的 注意: 强> 不要更改用户的文件的默认权限 的.ssh 目录,你最终会遇到不同的问题