首頁 > 運維 > linux運維 > 主體

linux高階拷貝指令scp怎麼使用

PHPz
發布: 2023-05-12 10:43:19
轉載
930 人瀏覽過

linux指令scp

scp — secure copy (remote file copy program):她是一個安全的遠端檔案拷貝程式。

synopsis :語法如下
scp [-12346bcpqrv] [-c cipher] [-f ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-p port] [- s program]

[[user@]host1:]file1 ... [[user@]host2:]file2

看到上面各種參數、選項都蒙了吧。不過,沒有關係,我們化整為零,一個一個來分析。
其實,這個指令和我們平常使用的cp 十分的相似。

scp 最簡單的用法就是 scp [[user@]host1:]file1 ... [[user@]host2:]file2 ,看懂麼?
看不懂也沒關係,舉個例子吧: 我要從192.168.1.2的linux 主機的/home/oracle/*.tar 檔案拷貝到192.168.1.3 的linux主機的/home/siebel下,就可以仿照上面的格式寫成:
scp oracle@192.168.1.2:/home/oracle/*.tar  siebel@192.168.1.3:/siebel/
輸入了以上指令,回車換行確認,可能會讓你輸入口令,依照提示輸入口令吧。
第一次執行的時候,出現以下錯誤:ssh: connect to host 192.168.1.99 port 22: connection refused, 於是將sshd 程式啟動,執行腳本: # /etc/init.d/sshd start, 成功解決以上問題。

至於該指令的其他參數,平常工作之中基本上用不到,所以,不舉例了,簡單給大家翻譯一下吧,以做參考。

description : 描述
scp copies files between hosts on a network.  it uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). ccp 1), scp will ask for passwords or passphrases if they are needed for authentication.
scp 在網絡主機之間拷貝數據,她使用ssh(1)來進行數據傳輸,同時使用相同的安全驗證方式。不像 rcp(1), scp 在必要的時候,會問口令。

the options are as follows:
具體的選項如下所示:
-1 forces scp to use protocol 1.
   強制scp 使用協定1

#-2 forces scp to use protocol 2.
強制scp 使用協議2

-3 copies between two remote hosts are transferred through the local host.without this option the data is copied
 directly between the twoote hosts.note that this option disables the progress meter.
透過本機主機在兩個遠端主機之間傳送資料。沒有這個選項,資料將直接在遠端主機間拷貝資料。注意:這個選項不支援進度條顯示。

-4 forces scp to use ipv4 addresses only.
強制scp只使用ipv4位址。

-6 forces scp to use ipv6 addresses only.
 強制scp只使用ipv6位址。

-b selects batch mode (prevents asking for passwords or passphrases).
 使用批次模式(避免詢問金鑰或口令)

#-c compression enable.passes the -c flag to ssh(1) to enable compression.
啟用壓縮。傳遞-c參數給ssh以啟用壓縮

-c cipher
 selects the cipher to use for encrypting the data transfer.this option is directly passed to ssh(1).
 選擇密碼加密資料資料封包傳輸,這個選項直接傳遞給ssh(1)。

-f ssh_config
 specifies an alternative per-user configuration file for ssh.this option is directly passed to ssh(1).
為ssh指定一個互動的使用者設定文件,這個選項被使用者設定文件直接傳遞給ssh(1)。

-l limit
 limits the used bandwidth, specified in kbit/s.
 限制使用的頻寬,以kb為單位。

-p port
 specifies the port to connect to on the remote host.
 在遠端主機上指定連結連接埠
-q quiet mode
 靜默模式:

-r recursively copy entire directories
遞歸拷貝整個目錄

-s program
 name of program to use for the encrypted connection.the program must understand ssh(1) options.
用來加密連結的程式。這個程式需要能夠辨識ssh(1)的選項。

exit status
執行後狀態
the scp utility exits 0 on success, and >0 if an error occurs.
scp 工具指令當成功執行後,回傳代碼為0,任何錯誤出現回傳代碼都大於0

以上是linux高階拷貝指令scp怎麼使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!