为Jenkins添加slave node
Linux slave机器上:
- 创建jenkins用户:sudo /usr/sbin/useradd -m jenkins -d /home/jenkins
- 设置用户jenkins的密码:sudo /usr/bin/passwd jenkins
- 切换到用户jenkins环境下:su - jenkins
- 生成public/private rsa key pair
ssh-keygen -t rsa -C "your_email@example.com"
cd ~/.ssh
cat id_rsa.pub > ~/.ssh/authorized_keys
chmod 700 authorized_keys - 修改配置文件中的以下记录 vim /etc/ssh/sshd_config
PermitEmptyPasswords no
PasswordAuthentication yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
StrictModes no - 重启服务: service sshd restart
Jenkins 上:
- Manage Jenkins -> Manage Nodes, New Node
- 输入node name, select "Permanent Agent",然后如下:
- 点击“Credentials”旁边的“Add”,添加private key,从linux上/home/jenkins/.ssh/id_rsa文件中把key拷贝过来。