溫馨提示×

如何通過CentOS SSH傳輸大文件

小樊
50
2025-07-06 11:16:14
欄目: 智能運維

要通過 CentOS SSH 傳輸大文件,可以使用 scp(secure copy)命令

  1. 使用 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 是遠程服務器上的目標目錄。

  1. 使用 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 是本地計算機上的目標目錄。

  1. 如果文件非常大,可以考慮使用壓縮工具(如 gzipzip)來減小文件大小,然后再進行傳輸。在傳輸完成后,可以在接收端解壓縮文件。

例如,在發送端壓縮文件:

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

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女