1. host key verification failed(主机秘钥核验失败)
问题分析:因为执行Jenkins任务的时候用的是Jenkins用户,但是,Jenkins用户到Tomcat主机上,没有做免密登陆。另外,Jenkins用户存在天生缺陷,需要手动修复,让其编程一个比较正常的用户,此后才可以以Jenkins的身份对Tomcat做免密登陆
[root@localhost ~]# tail -n2 /etc/passwd
tiechui:x:1000:1000:tiechui:/home/tiechui:/bin/bash
jenkins:x:988:983:Jenkins Automation Server:/var/lib/jenkins:/bin/false
此处有异常,Jenkins登陆环境为/bin/false,需要将其修改为/bin/bash
[root@localhost ~]# vim /etc/passwd
jenkins:x:988:983:Jenkins Automation Server:/var/lib/jenkins:/bin/bash
[root@localhost ~]# su jenkins
bash-4.2$
此时已经可以切换Jenkins用户了,但是,看起来并不完美,需要稍作调整
[root@localhost ~]# su jenkins
bash-4.2$ exit
exit
[root@localhost ~]# vim /root/.bash_profile #末行添加内容,如下
export PS1='[\u@\h \W]\$ '
[root@localhost ~]# source /root/.bash_profile
[root@localhost ~]# su jenkins
[jenkins@localhost root]$
[jenkins@localhost root]$ 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:
Your identification has been saved in /var/lib/jenkins/.ssh/id_rsa.
Your public key has been saved in /var/lib/jenkins/.ssh/id_rsa.pub.
The key fingerprint is:
1a:29:21:78:c9:28:63:a2:9e:22:49:eb:ae:12:6d:84 jenkins@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| |
| + . |
|*o= . |
|Eo.. . . |
|.+ . o S |
|+.= . o |
|+* . |
|= |
|=o |
+-----------------+
[jenkins@localhost root]$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.20.105
The authenticity of host '192.168.20.105 (192.168.20.105)' can't be established.
ECDSA key fingerprint is 91:21:75:d1:89:c6:0e:14:45:e3:7c:b7:63:9a:26:e0.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.20.105's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.20.105'"
and check to make sure that only the key(s) you wanted were added.
测试:
[jenkins@localhost root]$ ssh root@192.168.20.105
Last failed login: Wed Oct 9 14:55:00 CST 2019 from 192.168.20.104 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Wed Oct 9 14:53:59 2019 from 192.168.20.1
解决主机秘钥核验失败的问题
2. 关于备份数据的提示
关于备份数据,建议单独建立文件夹,以日期为文件夹名,这样好区分,提示如下:
[root@localhost ~]# A=`date +%Y%m%d%H%M%S`
[root@localhost ~]# echo $A
20191009164656