1、登录A机器
2、ssh-keygen -t rsa,将会生成密钥文件和私钥文件 id_rsa,id_rsa.pub或id_dsa,id_dsa.pub
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): [直接回车即可] Enter passphrase (empty for no passphrase): [若要建立无密码的ssh信任关系,这里直接回车!否则建立信任关系后,每次登陆远程机器均要求输入该密码] 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: b4:de:66:2c:c1:04:ad:7c:48:7c:f7:94:71:09:85:21 [email protected]
直接回车3次
key文件会保存在/root/.ssh目录下
这时候.ssh目下会多出几个文件
id_rsa 私钥文件
id_rsa.pub 公钥文件,这个文件里的内容要放到其它主机里面去。
查看 id_rsa.pub 文件
cat /roor/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIcAvh6Lz9ghftghtfghSv+kSrxVLC9UDKq27mg5vhfghAaWcgFgllZhfg2DLnGotmeL/08bp6jMW/ekSq1BY1eiouiluiliuliul2Rr84x0bB5YShhpgJwuPbwr/pymgukyukyukyuthjkiytiliunzdfkuykyuIZgVvgPTzNdN/RDwJMsafsdvgsdsfsdfdsfsdaflozStYcWjrwzYxsroDPBy4zjd0gH5zMYhj+vS4OOAZZ8rtHEfx+sTE0= [email protected]
时间: 2024-10-03 06:10:11