在CentOS系统中,使用SFTP(SSH File Transfer Protocol)传输大文件可以通过以下步骤完成:
安装OpenSSH服务器: 如果你的CentOS系统还没有安装OpenSSH服务器,可以使用以下命令进行安装:
sudo yum install openssh-server
启动并启用SSH服务: 确保SSH服务已经启动并设置为开机自启:
sudo systemctl start sshd
sudo systemctl enable sshd
配置防火墙: 如果你的CentOS系统启用了防火墙,确保允许SSH连接:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
连接到远程服务器:
使用SFTP客户端连接到远程服务器。你可以使用命令行工具sftp
或者图形化客户端如FileZilla。
sftp username@remote_host
其中username
是你的用户名,remote_host
是远程服务器的IP地址或域名。
传输大文件:
上传文件:
使用put
命令上传文件:
put /path/to/local/large_file.zip
这将把本地文件large_file.zip
上传到远程服务器的当前目录。
下载文件:
使用get
命令下载文件:
get /path/to/remote/large_file.zip /path/to/local/directory
这将从远程服务器下载文件large_file.zip
到本地目录。
使用SCP传输大文件: 如果你更喜欢使用SCP(Secure Copy Protocol),可以使用以下命令:
scp /path/to/local/large_file.zip username@remote_host:/path/to/remote/directory
scp username@remote_host:/path/to/remote/large_file.zip /path/to/local/directory
使用rsync传输大文件:
rsync
是一个更强大的文件传输工具,特别适合传输大文件和目录:
rsync -avz /path/to/local/large_file.zip username@remote_host:/path/to/remote/directory
rsync -avz username@remote_host:/path/to/remote/large_file.zip /path/to/local/directory
通过以上步骤,你可以在CentOS系统中使用SFTP、SCP或rsync传输大文件。这些工具都支持断点续传,因此在传输大文件时非常有用。