jenkins 本地机器:172.16.200.51
远程机器:172.16.200.134
1. 在jenkins机子里生成公钥和密钥 ssh-keygen -t rsa
2. 在远程机子里生成公钥和密钥 ssh-keygen -t rsa
3. 把jenkins里 把本地主机的公钥复制到远程主机的authorized_keys文件上
步骤2:在jenkins里:用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub root@172.16.200.134
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
[注: ssh-copy-id 把密钥追加到远程主机的 .ssh/authorized_key 上.]
4. 在远程机子里设置权限(远程机器:172.16.200.134)
(1)创建用户: ansible
(2)修改sshd_config文件
# vi /etc/ssh/sshd_config //开启以下内容
HostKey /etc/ssh/ssh_host_rsa_key
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
# /etc/init.d/sshd restart
(3)权限设置
# mkdir /home/ansible/.ssh
# chown -R ansible:ansible /home/ansible
# chmod 700 /home/ansible
# chmod 700 /home/ansible/.ssh
# chmod 644 /home/ansible/.ssh/authorized_keys //公钥文件的所有权限
# chmod 600 /home/ansible/.ssh/id_rsa //私钥文件的所有权限
### 可以测试远程连接了……
http://laowafang.blog.51cto.com/251518/1364298
5. 在jenkins里输入命令
[root@server ~]# su jenkins
[jenkins@server root]$ ssh root@172.16.200.134
Last login: Thu Jan 28 11:51:02 2016 from 172.16.200.134
[root@vm90 ~]#
远程机器:172.16.200.134
1. 在jenkins机子里生成公钥和密钥 ssh-keygen -t rsa
2. 在远程机子里生成公钥和密钥 ssh-keygen -t rsa
3. 把jenkins里 把本地主机的公钥复制到远程主机的authorized_keys文件上
步骤2:在jenkins里:用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub root@172.16.200.134
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
[注: ssh-copy-id 把密钥追加到远程主机的 .ssh/authorized_key 上.]
4. 在远程机子里设置权限(远程机器:172.16.200.134)
(1)创建用户: ansible
(2)修改sshd_config文件
# vi /etc/ssh/sshd_config //开启以下内容
HostKey /etc/ssh/ssh_host_rsa_key
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
# /etc/init.d/sshd restart
(3)权限设置
# mkdir /home/ansible/.ssh
# chown -R ansible:ansible /home/ansible
# chmod 700 /home/ansible
# chmod 700 /home/ansible/.ssh
# chmod 644 /home/ansible/.ssh/authorized_keys //公钥文件的所有权限
# chmod 600 /home/ansible/.ssh/id_rsa //私钥文件的所有权限
### 可以测试远程连接了……
http://laowafang.blog.51cto.com/251518/1364298
5. 在jenkins里输入命令
[root@server ~]# su jenkins
[jenkins@server root]$ ssh root@172.16.200.134
Last login: Thu Jan 28 11:51:02 2016 from 172.16.200.134
[root@vm90 ~]#