SFTP 本身不直接提供压缩功能,需结合其他工具实现,步骤如下:
使用命令行工具(如 Linux/macOS 的 zip
或 tar
):
zip -r archive.zip /path/to/directory
tar -czvf archive.tar.gz /path/to/directory
命令行 SFTP:
sftp username@remote_host
put archive.zip /remote/path/
exit
或 bye
图形界面工具(如 FileZilla、WinSCP):
通过 SSH 连接远程服务器,使用对应命令解压:
unzip archive.zip -d /目标路径/
tar -xzvf archive.tar.gz -C /目标路径/
注意:确保远程服务器有足够权限写入文件,大文件建议分块传输或使用断点续传功能。
引用来源: