1. ###传递文件
    2. [root@localhost ~]# scp abc.txt root@192.168.200.133:/root/
    3. The authenticity of host '192.168.200.133 (192.168.200.133)' can't be established.
    4. ECDSA key fingerprint is SHA256:cgOcmdXRgISyIWZj9qJshfy83uCWdYyFS0S25ugsZvg.
    5. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    6. Warning: Permanently added '192.168.200.133' (ECDSA) to the list of known hosts.
    7. root@192.168.200.133's password:
    8. abc.txt 100% 25 15.4KB/s 00:00
    9. ###生成rsa密钥
    10. [root@localhost ~]# ssh-keygen -t rsa
    11. Generating public/private rsa key pair.
    12. Enter file in which to save the key (/root/.ssh/id_rsa):
    13. Enter passphrase (empty for no passphrase):
    14. Enter same passphrase again:
    15. Your identification has been saved in /root/.ssh/id_rsa.
    16. Your public key has been saved in /root/.ssh/id_rsa.pub.
    17. The key fingerprint is:
    18. SHA256:8502BX98F3zXkmWYdQgmlz6YZRiiay8ULw+iAnRlbMM root@localhost.localdomain
    19. The key's randomart image is:
    20. +---[RSA 3072]----+
    21. | oo . oo+o ==|
    22. | oE . ..++ =+o|
    23. | . .. + *. oo+|
    24. |. . + o oo o+|
    25. |. . * S .o =|
    26. |. . + = o . o .o|
    27. |. . . o . = |
    28. | . . . . |
    29. | |
    30. +----[SHA256]-----+
    31. #### 将公钥传递到另一台服务器上
    32. [root@localhost ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.200.133
    33. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    34. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    35. /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
    36. root@192.168.200.133's password:
    37. Number of key(s) added: 1
    38. Now try logging into the machine, with: "ssh '192.168.200.133'"
    39. and check to make sure that only the key(s) you wanted were added.
    40. ####免密传输 scp -r 传递文件夹
    41. [root@localhost ~]# scp test.txt root@192.168.200.133:/root/
    42. test.txt 100% 31 26.2KB/s 00:00
    43. [root@localhost ~]#