[root@localhost ~]# ssh-keygen ///生成密钥对命令
Generating 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:2oL59QLNUNyK/ylwHD0nvd5/YcJZH0PiXknnJqDm6IE root@localhost.localdomain
The key's randomart image is:+---[RSA2048]----+|..|| o ... o.|| o o o..+.o|| o o * o..*o||BS=+o.+o+|| oEoO ..= o.|| o o=oo o .o .||. o+.o ...||. o..o|+----[SHA256]-----+
管理主机密钥对存放位置
[root@localhost ~]# cd /root/.ssh/[root@localhost .ssh]# ls
id_rsa(私钥) id_rsa.pub(公钥) known_hosts
将密钥发送至被控制主机
[root@localhost .ssh]# for i in{0,1,2};do ssh-copy-id -i 192.168.1.1$i ; done
被管理主机公钥存放位置
[root@test .ssh]# pwd
/root/.ssh
[root@test .ssh]# ls
authorized_keys(公钥密码)