简体   繁体   English

Jenkins 中的主机密钥验证失败

[英]Host key verification failed in Jenkins

I have the following shell script, which is to install puppet agent in a remote machine.我有以下shell脚本,它是在远程机器上安装puppet代理。 It worked perfectly if I run from my local ubuntu by cmd line as such: sh install_puppet_agent.sh如果我通过 cmd 行从我的本地 ubuntu 运行,它运行得很好: sh install_puppet_agent.sh

me@me:~$ cat install_puppet_agent.sh 
#!/bin/bash
echo "Installing ..."
ssh -t me@puppet-agent << 'INSTALL_PUPPET_AGENT'

wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
echo "mepassword" | sudo -S dpkg -i puppet6-release-bionic.deb

sudo apt-get update
sudo apt install -y puppet-agent
sudo touch /etc/puppetlabs/puppet/puppet.conf
sudo chmod 777 /etc/puppetlabs/puppet/puppet.conf
echo "[main]" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "certname = puppetagent" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "server = puppet" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "environment = production" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
echo "runinterval = 5m" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true

INSTALL_PUPPET_AGENT

echo "done"

me@me:~$ 

The I created a simple execute shell job in jenkins by copying the content of install_puppet_agent.sh to the Build -> Execute shell area, then I clicked save/build now, I got this:我通过将 install_puppet_agent.sh 的内容复制到 Build -> Execute shell 区域,在 jenkins 中创建了一个简单的执行 shell 作业,然后我现在单击保存/构建,我得到了这个:

Installing ...
Host key verification failed.
done

I have googled a while, unable to figure it out.我用谷歌搜索了一段时间,无法弄清楚。 I need to confess I am new to Jenkins & Puppet.我需要承认我是 Jenkins & Puppet 的新手。 Thanks谢谢

Assuming this is not a security problem that you are facing, you should be ok with updating the content of ~/.ssh/known_hosts file on the Jenkins node the job executes on.假设这不是您面临的安全问题,您应该可以在作业执行的 Jenkins 节点上更新~/.ssh/known_hosts文件的内容。

Examples how to do that:如何做到这一点的示例:

https://www.thegeekdiary.com/how-to-fix-the-error-host-key-verification-failed/ https://www.thegeekdiary.com/how-to-fix-the-error-host-key-verification-failed/

我只是通过配置 jenkins 作业来解决这个问题:

/home/me/install_puppet_agent.sh

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

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