在 CentOS 系統中,可以使用 scp
命令來通過 SSH 傳輸大文件。scp
是 Secure Copy 的縮寫,它可以在本地主機和遠程主機之間安全地傳輸文件。以下是使用 scp
命令傳輸大文件的步驟:
打開終端。
使用以下命令格式將文件從本地計算機復制到遠程計算機:
scp /path/to/local/file username@remote_host:/path/to/remote/directory
其中:
/path/to/local/file
是要傳輸的本地文件的路徑。username
是遠程主機上的用戶名。remote_host
是遠程主機的 IP 地址或域名。/path/to/remote/directory
是遠程主機上的目標目錄。例如,要將名為 largefile.tar.gz
的文件從本地計算機傳輸到遠程計算機的 /home/username/backup
目錄,可以使用以下命令:
scp /home/username/largefile.tar.gz username@192.168.1.100:/home/username/backup
輸入遠程主機的密碼(如果需要)。
等待文件傳輸完成。傳輸大文件可能需要一些時間,具體取決于文件大小和網絡速度。
注意:如果遠程主機使用的是非標準 SSH 端口,可以使用 -P
選項指定端口號:
scp -P port_number /path/to/local/file username@remote_host:/path/to/remote/directory
另外,如果你想在傳輸過程中顯示進度信息,可以使用 -v
選項:
scp -v /path/to/local/file username@remote_host:/path/to/remote/directory
如果你想保持文件的修改時間和訪問時間,可以使用 -p
選項:
scp -p /path/to/local/file username@remote_host:/path/to/remote/directory
如果你想遞歸地復制整個目錄,可以使用 -r
選項:
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory