Bootstrap

scp免密传输文件

准备两台可以相互传输文件的服务器A/B

1、在A服务器上,进入.ssh 目录;
cd ~/.ssh

2、在A服务器上面的.ssh目录下生成密钥;
ssh-keygen -t rsa

三次确认 enter

生成两个密钥,一个是私钥,一个是公钥;

root@ucddb202:~/.ssh# 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:yAe55iIQdsrKAyE+XYloVat0hI/nx7Nsa79y2O+MzWA root@ucddb202
The key's randomart image is:
+---[RSA 3072]----+
|   .oo           |
|  o.o o.         |
|++ +o=o          |
|*o=.++ +         |
|o= oo * S        |
|+..  + =         |
|.o. . + =E       |
|  .. . B.o*      |
|      o.=++*     |
+----[SHA256]-----+

3、将生成的密钥(id_rsa.pub)发送到B服务器上面;
scp id_rsa.pub username@ip:~/.ssh

例:scp id_rsa.pub [email protected]:~/.ssh/

4、B服务器上接收到的id_rsa.pub文件,追加到authorized_keys里面;

登录B服务器:
cd ~/.ssh

cat id_rsa.pub >>authorized_keys

5、在A服务器上对B 服务器上进行scp传输,无需输入密码;

;