要通过 CentOS SSH 传输大文件,可以使用 scp
(secure copy)命令
scp
命令从本地计算机复制到远程 CentOS 服务器:scp /path/to/local/large-file user@remote-server:/path/to/remote/directory
其中,/path/to/local/large-file
是要传输的本地文件的路径,user
是远程服务器上的用户名,remote-server
是远程服务器的 IP 地址或域名,/path/to/remote/directory
是远程服务器上的目标目录。
scp
命令从远程 CentOS 服务器复制到本地计算机:scp user@remote-server:/path/to/remote/large-file /path/to/local/directory
其中,user
是远程服务器上的用户名,remote-server
是远程服务器的 IP 地址或域名,/path/to/remote/large-file
是要传输的远程文件的路径,/path/to/local/directory
是本地计算机上的目标目录。
gzip
或 zip
)来减小文件大小,然后再进行传输。在传输完成后,可以在接收端解压缩文件。例如,在发送端压缩文件:
gzip /path/to/local/large-file
然后使用 scp
命令传输压缩后的文件:
scp /path/to/local/large-file.gz user@remote-server:/path/to/remote/directory
在接收端解压缩文件:
gunzip /path/to/remote/large-file.gz
或者,如果使用了 zip
命令压缩文件:
zip /path/to/local/large-file.zip /path/to/local/large-file
传输压缩后的文件:
scp /path/to/local/large-file.zip user@remote-server:/path/to/remote/directory
在接收端解压缩文件:
unzip /path/to/remote/large-file.zip
注意:在使用 scp
命令时,可能需要输入远程服务器用户的密码。为了方便传输,可以考虑配置 SSH 密钥认证,以避免每次传输都需要输入密码。