要通過 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 密鑰認證,以避免每次傳輸都需要輸入密碼。