要求:需要从A免密码输入复制文件至B。
1. 在主机A上执行如下命令来生成配对密钥:
[iyunv@wqk1 mnt]# 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:
ec:3e:ae:d2:a6:64:db:98:87:78:11:e6:a2:d9:c4:a4 root@wqk1.object.com
[iyunv@wqk1 mnt]# cd ~/.ssh/
[iyunv@wqk1 .ssh]# ls
id_rsa id_rsa.pub known_hosts
2. 将 .ssh 目录中的 id_rsa.pub 文件复制到 主机B 的 ~/.ssh/ 目录中,并改名为 authorized_keys。
[iyunv@wqk1 .ssh]# scp id_rsa.pub root@192.168.10.107:/root/.ssh/authorized_keys