Jenkins Quick Start - Part 1 - Preparing Environment -- Build Accounts
2018年04月27日
[root@* ~]# vim /etc/passwd
将“jenkins:x:997:995:Jenkins Automation Server:/var/lib/jenkins:/bin/false”替换为“jenkins:x:997:995:Jenkins Automation Server:/var/lib/jenkins:/bin/bash”
[root@* ~]# passwd jenkins
[root@* ~]# vim /etc/ssh/sshd_config
[root@* ~]# sudo systemctl restart sshd
[root@* ~]# su - jenkins
-bash-4.2$ pwd
/var/lib/jenkins
-bash-4.2$ ssh-keygen
-bash-4.2$ ssh-copy-id jenkins@localhost
-bash-4.2$ ssh localhost
-bash-4.2$ exit
-bash-4.2$ exit
logout
[root@* ~]# visudo
在
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
下面再加一行:
Note
在vim里按“/”键,进入搜索模式。
再开启一台ECS(CentOS7),作为Jenkins Slave node。
SSH login to this server.
[centos@* ~]$ sudo su -
[root@jenkinsslave ~]# adduser jenkins
[root@jenkinsslave ~]# passwd jenkins
[root@jenkinsslave ~]# visudo
在
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
的下面再加一行:
[root@jenkinsslave ~]# vim /etc/ssh/sshd_config
[root@jenkinsslave ~]# sudo systemctl restart sshd
On the Jenkins Master node
[root@* ~]# su - jenkins
使用Jenkins Slave node的内网IP地址。拷贝到Jenkins Slave node。
-bash-4.2$ ssh-copy-id jenkins@10.0.0.x
-bash-4.2$ ssh 10.0.0.x
[jenkins@jenkinsslave ~]$ exit
On the Jenkins Master node:
[root@* ~]# cat /etc/passwd | grep jenkins
jenkins:x:997:995:Jenkins Automation Server:/var/lib/jenkins:/bin/false
[root@* ~]# vim /etc/passwd
将“jenkins:x:997:995:Jenkins Automation Server:/var/lib/jenkins:/bin/false”替换为“jenkins:x:997:995:Jenkins Automation Server:/var/lib/jenkins:/bin/bash”
[root@* ~]# passwd jenkins
Changing password for user jenkins. New password: Retype new password: passwd: all authentication tokens updated successfully.
[root@* ~]# vim /etc/ssh/sshd_config
... PasswordAuthentication yes ...
[root@* ~]# sudo systemctl restart sshd
[root@* ~]# su - jenkins
-bash-4.2$ pwd
/var/lib/jenkins
-bash-4.2$ ssh-keygen
Generating public/private rsa key pair. Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa): Created directory '/var/lib/jenkins/.ssh'. 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: SHA256:*** jenkins@ip-10-0-0-*.us-west-2.compute.internal The key's randomart image is: +---[RSA 2048]----+ ... +----[SHA256]-----+
-bash-4.2$ ssh-copy-id jenkins@localhost
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/jenkins/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys jenkins@localhost's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'jenkins@localhost'" and check to make sure that only the key(s) you wanted were added.
-bash-4.2$ ssh localhost
-bash-4.2$ exit
-bash-4.2$ exit
logout
[root@* ~]# visudo
在
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
下面再加一行:
jenkins ALL=(ALL) NOPASSWD: ALL
Note
在vim里按“/”键,进入搜索模式。
再开启一台ECS(CentOS7),作为Jenkins Slave node。
SSH login to this server.
[centos@* ~]$ sudo su -
[root@jenkinsslave ~]# adduser jenkins
[root@jenkinsslave ~]# passwd jenkins
Changing password for user jenkins. New password: Retype new password: passwd: all authentication tokens updated successfully.
[root@jenkinsslave ~]# visudo
在
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
的下面再加一行:
jenkins ALL=(ALL) NOPASSWD: ALL
[root@jenkinsslave ~]# vim /etc/ssh/sshd_config
... PasswordAuthentication yes ...
[root@jenkinsslave ~]# sudo systemctl restart sshd
On the Jenkins Master node
[root@* ~]# su - jenkins
使用Jenkins Slave node的内网IP地址。拷贝到Jenkins Slave node。
-bash-4.2$ ssh-copy-id jenkins@10.0.0.x
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/jenkins/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys jenkins@10.0.0.*'s password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'jenkins@10.0.0.*'" and check to make sure that only the key(s) you wanted were added.
-bash-4.2$ ssh 10.0.0.x
[jenkins@jenkinsslave ~]$ exit