在CentOS系統中,可以使用scp
(Secure Copy Protocol)命令進行文件傳輸。scp
是一個基于SSH的文件傳輸工具,可以在本地計算機和遠程計算機之間安全地傳輸文件。
以下是使用scp
進行文件傳輸的基本語法:
scp /path/to/local/file username@remote_host:/path/to/remote/directory
scp username@remote_host:/path/to/remote/file /path/to/local/directory
scp username1@remote_host1:/path/to/remote/file username2@remote_host2:/path/to/remote/directory
在這些示例中,需要將/path/to/local/file
、/path/to/remote/file
、/path/to/remote/directory
、username
、remote_host
等替換為實際的文件路徑、用戶名和主機名。
例如,要將本地文件example.txt
復制到遠程計算機192.168.1.100
上的/home/username/documents
目錄,可以使用以下命令:
scp example.txt username@192.168.1.100:/home/username/documents
在執行scp
命令時,系統會提示輸入遠程計算機的用戶密碼。輸入正確的密碼后,文件傳輸將開始。
注意:在使用scp
進行文件傳輸時,請確保目標計算機上已啟用SSH服務,并且防火墻允許SSH連接。