ssh-keygen私钥配置说明-ssh scp rsync等传输数据无需密码

作者:动易软件 来源:本站原创 点击数: 发布时间:2024年06月12日

1,在主服务器执行ssh-keygen -t rsa,完成后会在/root/.ssh/目录生成id_rsa id_rsa.pub

[root@pg1 ~]# 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:
14:18:7d:5d:2e:6c:b5:2a:2c:25:fe:2e:dc:cd:d7:83 root@pg1

 2,把id_rsa 复制到备服务器/root/.ssh/目录下

 3,在主服务器上把生成的 /root/.ssh/id_rsa.hub 名称更改为authorized_keys,原来默认的可以更名备份一下

 4,连接测试

在备服务器上通过命令 ssh  -i  ~/.ssh/id_rsa  root@[主服务器IP]  
#
无密码能够直接成功连接表示配置成功