传递文件
[root@localhost ~]# scp abc.txt root@192.168.200.133:/root/
The authenticity of host ‘192.168.200.133 (192.168.200.133)’ can’t be established.
ECDSA key fingerprint is SHA256:cgOcmdXRgISyIWZj9qJshfy83uCWdYyFS0S25ugsZvg.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘192.168.200.133’ (ECDSA) to the list of known hosts.
root@192.168.200.133‘s password:
abc.txt 100% 25 15.4KB/s 00:00
生成rsa密钥
[root@localhost ~]# 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:8502BX98F3zXkmWYdQgmlz6YZRiiay8ULw+iAnRlbMM root@localhost.localdomain
The key’s randomart image is:
+—-[RSA 3072]——+
| oo . oo+o ==|
| oE . ..++ =+o|
| . .. + . oo+|
|. . + o oo o+|
|. . S .o =|
|. . + = o . o .o|
|. . . o . = |
| . . . . |
| |
+——[SHA256]——-+
将公钥传递到另一台服务器上
[root@localhost ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.200.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys
root@192.168.200.133‘s password:
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘192.168.200.133’”
and check to make sure that only the key(s) you wanted were added.
免密传输
[root@localhost ~]# scp test.txt root@192.168.200.133:/root/
test.txt 100% 31 26.2KB/s 00:00
[root@localhost ~]#
