为Jenkins添加slave node

Linux slave机器上:

  1. 创建jenkins用户:sudo /usr/sbin/useradd -m jenkins -d /home/jenkins
  2. 设置用户jenkins的密码:sudo /usr/bin/passwd jenkins
  3. 切换到用户jenkins环境下:su - jenkins
  4. 生成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
  5. 修改配置文件中的以下记录 vim /etc/ssh/sshd_config
    PermitEmptyPasswords no
    PasswordAuthentication yes
    RSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys
    StrictModes no
  6. 重启服务: service sshd restart

 

Jenkins 上:

  1. Manage Jenkins -> Manage Nodes, New Node
  2. 输入node name, select "Permanent Agent",然后如下:
  3. 点击“Credentials”旁边的“Add”,添加private key,从linux上/home/jenkins/.ssh/id_rsa文件中把key拷贝过来。

posted on 2017-09-18 15:55  熊gg  阅读(3579)  评论(0编辑  收藏  举报