Linux命令列二 遠端複製命令 scp

2021-07-24 07:54:13 字數 3776 閱讀 7910

在 linux 下 scp 命令主要用來在不同主機之間做資料(檔案或者目錄)的安全拷貝的。scp 命令可以將資料(檔案或者目錄)從本地計算機中拷貝到遠端計算機中,或者從遠端計算機中拷貝資料(檔案或者目錄)到本地計算機,scp 命令使用安全加密協議,所以在遠端拷貝資料的時候會比較安全,不會被黑客擷取。如有不正之處,歡迎批評指正。

語法:

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

引數項:

-1      強制scp命令使用協議ssh1。

-2 強制scp命令使用協議ssh2.

-3copies 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.

-4 強制scp命令僅使用ipv4進行傳輸。

-6 強制scp命令僅使用ipv6進行傳輸。

-b 使用批處理模式(傳輸過程中不詢問傳輸口令或短語)。

-c 允許壓縮。(將-c標誌傳遞給ssh,從而開啟壓縮功能)。

-c cipher 以cipher將資料傳輸進行加密,這個選項將直接傳遞給ssh。

-f ssh_config 指定乙個替代的ssh配置檔案,此引數直接傳遞給ssh。

-i identity_file 從指定檔案中讀取傳輸時使用的金鑰檔案,此引數直接傳遞給ssh。

-l limit 限定使用者所能使用的頻寬,以kbit/s為單位。

-o ssh_option 如果習慣於使用ssh_config(5)中的引數傳遞方式。引數如下:

addressfamily

batchmode

bindaddress

canonicaldomains

canonicalizefallbacklocal

canonicalizehostname

canonicalizemaxdots

canonicalizepermittedcnames

certificatefile

challengeresponseauthentication

checkhostip

cipher

ciphers

compression

compressionlevel

connectionattempts

connecttimeout

controlmaster

controlpath

controlpersist

globalknownhostsfile

gssapiauthentication

gssapidelegatecredentials

hashknownhosts

host

hostbasedauthentication

hostbasedkeytypes

hostkeyalgorithms

hostkeyalias

hostname

identitiesonly

identityagent

identityfile

ipqos

kbdinteractiveauthentication

kbdinteractivedevices

kexalgorithms

loglevel

macs

nohostauthenticationforlocalhost

numberofpasswordprompts

passwordauthentication

pkcs11provider

port

preferredauthentications

protocol

proxycommand

proxyjump

pubkeyacceptedkeytypes

pubkeyauthentication

rekeylimit

rhostsrsaauthentication

rsaauthentication

sendenv

serveraliveinterval

serveralivecountmax

stricthostkeychecking

tcpkeepalive

updatehostkeys

useprivilegedport

user

userknownhostsfile

verifyhostkeydns

-p port 注意是大寫的p, port是指定資料傳輸用到的埠號。

-p 保留原檔案的修改時間,訪問時間和訪問許可權。

-q quiet模式:不顯示傳輸進度條。

-r 遞迴複製整個目錄。

-s program 指定加密傳輸時所使用的程式。此程式必須能夠理解ssh(1)的選項。

-v verbose模式:詳細方式顯示輸出。scp和ssh(1)會顯示出整個過程的除錯資訊。這些資訊用於除錯連線,驗證和配置問題。

從本地計算機複製目錄到遠端計算機上

將本地計算機/home/tools目錄複製到遠端計算機(ip:10.10.10.10)的/home/tools1/目錄,複製後的目錄結構為/home/tools1/tools

scp -r -p

2222 /home/tools/ [email protected]

:/home/tools1

如果只想複製/home/tools/目錄下的內容到/home/tools1/目錄。命令如下:

scp -r -p

2222 /home/tools/* [email protected]

:/home/tools1

從遠端計算機複製目錄到本地計算機上

將遠端計算機(ip:10.10.10.10)/home/tools目錄複製到本地計算機的/home/tools1/目錄,複製後的目錄結構為/home/tools1/tools

scp -r -p

2222 [email protected]

:/home/tools /home/tools1/

如果只想複製/home/tools/目錄下的內容到/home/tools1/目錄。命令如下:

scp -r -p

2222 [email protected]

:/home/tools/* /home/tools1/

scp 命令詳解

Linux命令列學習(二)

ps topkill kill allmount 輸出當前系統掛載的裝置列表 的裝置檔名 掛載到虛擬目錄的掛載點 檔案系統型別 已掛載 的訪問狀態 mount t type device directory 手動掛載裝置的基本命令 type引數 vfat windows長檔案系統 ntfs win ...

Linux命令列svn命令

1 linux命令列下將檔案checkout到本地目錄 svn checkout path path是伺服器上的目錄 例如 svn checkout svn 如果第一次使用svn,要使用 使用者名稱 密碼 svn checkout svn user password 簡寫 svn co 2 linu...

Linux命令列與命令

linux的命令是很重要的工具,也往往是初學者最大的瓶頸。有朋友用了很長時間的linux圖形介面,基本不使用命令列輸入命令執行,所以裝的linux最終成了擺設。這裡總結一些命令列下常使用的命令,希望能有用。什麼是命令 我們通常所說的linux命令列是執行在終端 terminal 的shell 閱讀l...