生成秘钥
在jenkins所在服务器生成秘钥
[root@instance-6yplt440 dist]# cd ~/.ssh
[root@instance-6yplt440 .ssh]# ls
authorized_keys
[root@instance-6yplt440 .ssh]# ssh-keygen -t rsa -C "jenkins"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:UtpIL7POq1ZpIHiQLsUhhj0Fn4H6/Nas6NdvKcejyYo jenkins
The key's randomart image is:
+---[RSA 2048]----+
|o=o=o |
|=.*. o |
|.= .o . . |
|+.o .. * |
|.+ . .*.S |
| o += |
| . *.. . |
| o=+=.* |
| .E+++BB.. |
+----[SHA256]-----+
重命名秘钥文件名
[root@instance-6yplt440 .ssh]# ls
authorized_keys id_rsa id_rsa.pub
[root@instance-6yplt440 .ssh]# mv id_rsa id_rsa_jenkins
[root@instance-6yplt440 .ssh]# ls
authorized_keys id_rsa_jenkins id_rsa.pub
[root@instance-6yplt440 .ssh]# mv id_rsa.pub id_rsa_jenkins.pub
[root@instance-6yplt440 .ssh]# ls
authorized_keys id_rsa_jenkins id_rsa_jenkins.pub
添加公钥至github账户中
Github -> settings -> SSH and GPG keys -> New SSH key
添加私钥至jenkins项目
显示私钥