跳转至

12. jenkins免密登录其他服务器设置

1. 生成密钥

# 10.0.8.5
ssh-keygen -t rsa

2. 分发密钥

# 10.0.8.5
ssh-copy-id ubuntu@10.0.8.2
ssh-copy-id ubuntu@10.0.8.3
# 需要输入用户名密码!

演示

root@4c16g:/service# ssh-copy-id ubuntu@10.0.8.2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ubuntu@10.0.8.2's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'ubuntu@10.0.8.2'"
and check to make sure that only the key(s) you wanted were added.

root@4c16g:/service#

3. 免密登录测试!

root@4c16g:/service# ssh 'ubuntu@10.0.8.2'
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-90-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue 22 Feb 2022 02:25:31 PM CST

  System load:                      0.41
  Usage of /:                       37.7% of 78.69GB
  Memory usage:                     74%
  Swap usage:                       0%
  Processes:                        231
  Users logged in:                  0
  IPv4 address for br-71d53729b5c1: 172.18.0.1
  IPv4 address for br-e91a57c24883: 172.19.0.1
  IPv4 address for docker0:         172.17.0.1
  IPv4 address for eth0:            10.0.24.3
  IPv4 address for tunl0:           10.244.16.192
  IPv4 address for wg0:             10.0.8.2


Last login: Mon Feb 21 11:40:08 2022 from 122.5.31.182
ubuntu@zabbix:~$

最后更新: 2022-02-22 12:50:43