需求条件
主机A: 192.168.1.120
主机B: 192.168.1.121
实现:主机B 免密登录 主机A
配置主机B,操作步骤如下:
1、安装好ssh,查看ssh可用
输入 ssh
2、使用命令ssh-keygen -t rsa生成rsa密钥, 一路回车
[root@VM_0_3_centos /]# ssh-keygen -t rsa 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:qfosnfTfw2FbXJ0ZfOkk6Mc2ykm9fmw5RAsW12w root@VM_0_3_centos The key's randomart image is: +---[RSA 2048]----+ | +.o+o .. | | . o BE= *| | =.O +=+| | . O +o =| | . S + + o= | | o o . =. | | . .. . +o | | ... o . o...| | .+.. . .... | +----[SHA256]-----+
3、将文件远程复制到主机A目录下
ssh-copy-id root@192.168.1.120 -p 22