前言
本文仅仅简单介绍了SCP、SSH、密钥、密钥对。
第一部分:SCP(Secure Copy Protocol)
功能
SCP(Secure Copy Protocol)是一种基于SSH协议的文件传输工具,用于在本地和远程主机之间安全地复制文件。它利用SSH的加密机制,确保数据传输的安全性。
使用方法
1.从本地复制到远程主机
scp /path/to/local/file username@remote_host:/path/to/remote/directory
/path/to/local/file:本地文件路径。
username@remote_host:远程主机的用户名和地址。
/path/to/remote/directory:远程主机上的目标目录。
2.从远程主机复制到本地
scp username@remote_host:/path/to/remote/file /path/to/local/directory
username@remote_host:/path/to/remote/file:远程主机上的文件路径。
/path/to/local/directory:本地目标目录。
3.复制整个目录
使用 -r 选项递归复制目录:
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory
4.指定端口
如果SSH服务使用非默认端口(默认22),使用 -P 选项指定端口:
scp -P 2222 /path/to/local/file username@remote_host:/path/to/remote/directory
5.压缩传输
使用 -C 选项启用压缩,加快传输速度:
scp -C /path/to/local/file username@remote_host:/path/to/remote/directory
第二部分:SSH(Secure Shell)
功能
SSH(Secure Shell)是一种加密网络协议,用于安全地访问和管理远程主机。它提供加密的通信通道,支持远程登录、命令执行和文件传输。
使用方法
1.远程登录
s