如何实现所有克隆主机免密使用sshd服务
1.在母盘中生成密钥[rootlocalhost ~]# 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_rsaYour public key has been saved in/root/.ssh/id_rsa.pubThe key fingerprint is:SHA256:xI09y3igkbSz03FbXaDZqG990HuLkVNHYwtv85/tCY rootlocalhost.localdomainThe keys randomart image is:---[RSA 3072]----| . o|| . B o|| * ..|| B * . o.|| S . o..|| . . o.|| . *.|| E.*|| **|----[SHA256]-----注意标红处的文件由于版本的不一致可能会导致文件名不一致自己虚拟机生成什么文件名就用什么文件名一定注意不要用错了2.给root用户上锁[rootlocalhost ~]# ssh-copy-id -i/root/.ssh/id_rsa.pubrootlocalhost/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 keysrootlocalhosts password: #输入你的密码Number of key(s) added: 1Now try logging into the machine, with: ssh rootlocalhostand check to make sure that only the key(s) you wanted were added.注意标红处文件名英同第一步一致3.为新建用户实现免密[rootlocalhost ~]# cp -rp /root/.ssh/ /etc/skel/4.测试将母盘关机用母盘克隆出两台虚拟机在虚拟机上使用ssh rootlocalhost即可在其中一个虚拟机创建一个新的普通用户切换至新建的普通用户使用ssh命令即可实现免密登录