SSH下文件传输
- categories
- >
- Tool
使用 scp 和 lrzsz
scp
scp — OpenSSH secure file copy
本地->远程
scp file remote_username@remote_ip:/path/to/file
远程->本地
scp file remote_username@remote_ip:/path/to/file
如果是整个目录,添加选项-r
scp -r folder remote_username@remote_ip:/path/to/file
lrzsz
用于在远程 Linux 服务器和本地 Windows 系统之间传输文件
sudo apt install lrzsz
- 发送文件到远程服务器
在远程服务器的终端(如 ssh 连接)中运行:
rz
然后在本地 选择要上传的文件,终端会自动接收并存储到当前目录。
或者直接:
rz -y # 自动覆盖同名文件
- 从远程服务器下载文件
在远程服务器上运行:
sz filename
然后在本地 接收文件,默认存储在终端软件的下载目录中。
如果需要 批量下载多个文件:
sz file1 file2 file3
或者:
sz -y file1 file2 # 自动覆盖本地文件
comment:
- Valine
- LiveRe
- ChangYan