免密登录
A登录B
A
1. ssh-keygen
root@ubuntu:~# ssh-keygenGenerating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:EXnWo89OEFM1glhqMiN8U/uGYk6zGLMapIYjbacqijI root@ubuntu
The key"s randomart image is:
+---[RSA 2048]----+
| o+.+o.o |
| . .o+* o. . |
| o * =o + . |
| o * +o |
| . o = S o+ |
|.+ O + . + |
|=.+ + o o |
|Eo = . |
|Boo |
+----[SHA256]-----+
2. 获取公钥信息
root@ubuntu:~# cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0jAAcd/+8Nu/K/lH9ZLybafwnxgCeTVzTt5nfSHrr/hUmj+Rk7249NoYdT5wuZTHFYZS0ItIp1rNym/wOml2cS5NbTBs1N78RlZf29GS2ufZewHFFLP698m0X8uNfgPnSJfNGJXgMc1uGmcRQ7z3Wp8nymrOVosr9oUHlZk5XljtXpaZbWJ7GpaYnzZVaMTGgBtBubdZk72LBNp6qBTYePJGjCAAK5PDtYUJjKmiO2rtsI6g8rKdmtb6PW/u6yPoVdGyMQh+cdMV2vNtW3+xfmjaO+EMqbS9K3sBRjleqmQGORPzoFTHYxDyFisw/o+5zdlApg+3F8Eru7sSoDQKP root@ubuntu
B
1.写入A的公钥
vim ~/.ssh/authorized_keys# 写入A的公钥信息
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0jAAcd/+8Nu/K/lH9ZLybafwnxgCeTVzTt5nfSHrr/hUmj+Rk7249NoYdT5wuZTHFYZS0ItIp1rNym/wOml2cS5NbTBs1N78RlZf29GS2ufZewHFFLP698m0X8uNfgPnSJfNGJXgMc1uGmcRQ7z3Wp8nymrOVosr9oUHlZk5XljtXpaZbWJ7GpaYnzZVaMTGgBtBubdZk72LBNp6qBTYePJGjCAAK5PDtYUJjKmiO2rtsI6g8rKdmtb6PW/u6yPoVdGyMQh+cdMV2vNtW3+xfmjaO+EMqbS9K3sBRjleqmQGORPzoFTHYxDyFisw/o+5zdlApg+3F8Eru7sSoDQKP root@ubuntu
A
测试
root@ubuntu:~# ssh 10.241.4.3
以上是 免密登录 的全部内容, 来源链接: utcz.com/z/518927.html