scp做法
SCP(Secure Copy Protocol)是一种基于SSH的文件传输协议,用于在本地和远程计算机之间安全地传输文件。以下是SCP的一些常见用法:
从本地复制到远程服务器
scp /path/to/local/file username@remote_host:/path/to/remote/directory
```
从远程服务器复制到本地:
```
scp username@remote_host:/path/to/remote/file /path/to/local/directory
```bash
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory
```
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory
指定端口号进行传输
通过SSH密钥进行认证
```bash
scp -i /path/to/private_key /path/to/local/file username@remote_host:/path/to/remote/directory
```
scp -i /path/to/private_key /path/to/local/file username@remote_host:/path/to/remote/directory
递归复制整个目录及其所有子目录和文件
显示传输进度条
```bash
scp -v /path/to/local/file username@remote_host:/path/to/remote/directory
```