需要在 A上面生成免密码的公钥,添加到B的authorized_keys文件中。
现在是实例:
在机器SC-1上,执行ssh-genken
步骤1
点击(此处)折叠或打开
- #
ssh-keygen -b 1024 -t rsa - Generating public/private rsa key pair.
- Enter
file in which to save the key (/root/.ssh/id_rsa): 【1】《-- 直接Enter键 - Enter passphrase
(empty for no passphrase): 【2】《-- 直接Enter键 - Enter same passphrase again:
【3】《-- 直接Enter键 - Your identification has been saved in
/root/.ssh/id_rsa. 【4】 - Your public key has been saved in
/root/.ssh/id_rsa.pub. 【5】 - The key fingerprint is:
- 95:3e:1b:a0:e4:ff:81:ad:0b:e3:c6:81:d6:26:1c:6e root@SC-1
- The key's randomart image is:
- +--[ RSA 1024]----+
- |
| - |
. | - |
. . o | - |
.o . + | - |
o +o S + | - |
E +. o + | - |
o +o.o + | - |
.oo o . | - |
.. o.. | - +-----------------+
注释
【1】保存路径,回车默认
【2】输入密码,回车表示密码为空
【3】重复输入密码,同上
【4】私钥位置
【5】公钥位置
在A上拷贝,scp /root/.ssh/id_rsa.pub
在B上添加key记录,
cd /root/.sshOK, 享受scp免输入密码的劲爽吧!
catauthorized_keys.sc-1 >> authorized_keys