我们可以利用Role-based Authorization Strategy插件来管理jenkins用户权限
持续集成环境4-Jenkins凭证管理
凭据可以用来存储需要密文保护的数据库密码、Gitlab密码信息、Docker私有仓库密码等,以便Jenkins可以和这些第三方进行交互。
安装Credentials Binding插件
安装Git工具
#在Jenkins服务器上安装Git工具
yum -y install git
安装Git插件
普通密码拉取仓库代码
拉取文件的保存位置
SSH密钥类型
在enkins服务器中生成公钥
[root@localhost updates]# cd /var/lib/jenkins/workspace/itcast01
[root@localhost itcast01]# ll
总用量 0
-rw-r--r--. 1 jenkins jenkins 0 4月 20 13:46 README.md
[root@localhost itcast01]# ssh-keygen -t rsa
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:NXhvLQFWQC1vuaKSPn78Y98fOmTCC/Y3s8tJv+CEDwQ [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| .=+. |
| o... |
| .E+o.. |
| o.o+o |
| S .o+.. |
| oo+o+ |
| o..o+=+ . |
| + + ooB*= .|
| oo+ o.ooOB+o|
+----[SHA256]-----+
[root@localhost itcast01]# cd /root/.ssh
[root@localhost .ssh]# ll
总用量 12
-rw-------. 1 root root 1679 4月 20 13:57 id_rsa
-rw-r--r--. 1 root root 408 4月 20 13:57 id_rsa.pub
-rw-r--r--. 1 root root 177 4月 18 13:49 known_hosts
[root@localhost .ssh]#
将生成的公钥文件放置到gitlab 设置的SSH Keys中
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEywP+eQXTZgNozxZvwlQRHczfzOTym2XBBnTVYdcP7Cpy/otX5fmE70h1fxRijZtvIQuWwEGSBTw+fqaU+nvey9SWrIL0u48NhrNkCW0U3Fl5JBW2PcEjzR7M4RvzmPiQJJY3053uF0VAgwJ2QpRxcU01HXZW4ei6VbqS//abUAZiRUo9gwMhJ9kuL3bZmTu2kG5R3CVfaMWUAmMuy5pzKp2NsC4UfbudtKIHuWOC3CMhUejbPRqrflZ0HMXDZOyELqlRiW4+/2KZZr//AJSs/OKhiFWpdFjFJSAQGU2Jf2vxxW9wTlHmEl9uKq1m2+JFi7jS7rI51KR1XiByGcJZ [email protected]
将私钥放置在凭据中
选择SSH连接
通过SSH的方式将代码拉去下来了
标签:rsa,ssh,key,Jenkins,全局,权限,root,id,localhost From: https://blog.51cto.com/HMJP/5768317