Jenkins+gitlab+tomcat部署项目时遇到的问题及解决办法

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
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值