linux高級拷貝命令scp怎么使用

linux命令scp

scp — secure copy (remote file copy program):她是一個安全的遠(yuǎn)程文件拷貝程序。

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

看到上面各種參數(shù)、選項蒙了吧。不過,沒有關(guān)系,我們化整為零,一個一個來分析。
其實,這個命令和我們平時使用的cp 十分的相似。

scp 最簡單的用法就是 scp [[user@]host1:]file1 … [[user@]host2:]file2 ,能看懂么?
看不懂也沒有關(guān)系,舉個例子吧: 我要從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/
輸入完了以上命令,回車換行確認(rèn),可能會讓你輸入口令,根據(jù)提示輸入口令吧。
第一次執(zhí)行的時候,出現(xiàn)如下錯誤:ssh: connect to host 192.168.1.99 port 22: connection refused, 于是將 sshd 程序啟動,執(zhí)行腳本: # /etc/init.d/sshd start, 成功解決以上問題。

至于該命令的其他參數(shù),平時工作之中基本用不到,所以,不舉例了,簡單給大家翻譯一下吧,以做參考。

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).? unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
scp 在網(wǎng)絡(luò)主機之間拷貝數(shù)據(jù),她使用ssh(1)來進(jìn)行數(shù)據(jù)傳輸,同時使用相同的安全驗證方式。不象 rcp(1), scp 在必要的時候,會詢問口令。

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

-2 forces scp to use protocol 2.
強制 scp 使用協(xié)議2

-3 copies between two remote hosts are transferred through the local host.without this option the data is copied
?directly between the two remote hosts.note that this option disables the progress meter.
通過本機主機在兩個遠(yuǎn)程主機之間傳輸數(shù)據(jù)。沒有這個選項,數(shù)據(jù)將直接在遠(yuǎn)程主機間拷貝數(shù)據(jù)。 注意:這個選項不支持進(jìn)度條顯示。

-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參數(shù)給ssh以啟用壓縮

-c cipher
?selects the cipher to use for encrypting the data transfer.this option is directly passed to ssh(1).
?選擇密碼加密數(shù)據(jù)傳輸,這個選項被直接傳遞給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.
?在遠(yuǎn)程主機上指定鏈接端口
-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
執(zhí)行后狀態(tài)
the scp utility exits 0 on success, and >0 if an Error occurs.
scp 工具命令當(dāng)成功執(zhí)行后,返回代碼為0, 任何錯誤出現(xiàn)返回代碼都大于0

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊8 分享