配置jenkins注意事项
1、ssh版本过高
# 提示信息
jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey: [B@60373f7]
正常密钥生成指令
[root@localhost ~]# ssh-keygen -t rsa
[root@localhost ~]# cat .ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9u...
可以注意到密钥的首行是:
-----BEGIN OPENSSH PRIVATE KEY-----
这个在jenkins有些版本并不支持这种格式
解决方案:
[root@localhost ~]# ssh-keygen -m PEM -t rsa -b 4096
[root@localhost ~]# cat .ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAwIR8JI/8nwMKANbdo1Upcw5...
密钥首行变成:
-----BEGIN RSA PRIVATE KEY-----
2、为jenkins创建独立用户
# 提示信息
jenkins.plugins.publish_over.BapPublisherException: Failed to connect session for config [xxx]. Message [Auth fail]
解决方案:
[root@localhost ~]# sudo useradd jenkins
[root@localhost ~]# sudo passwd jenkins
[root@localhost ~]# su jenkins
[root@localhost ~]# ssh-keygen -m PEM -t rsa -b 4096
使用这个方案要注意在配置页面也要输入该用户的密码
作者信息
Sean
Stay hungry,Stay foolish.