溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

scp命令語法

發(fā)布時間:2020-06-07 13:51:54 來源:網(wǎng)絡(luò) 閱讀:1002 作者:運(yùn)維小成 欄目:安全技術(shù)

1、將本地文件拷貝到遠(yuǎn)端

scp 文件 用戶@ 主機(jī)名:遠(yuǎn)端目錄
scp 123.txt root@192.168.1.1:/

2、將遠(yuǎn)端目錄拷貝到本地

scp -r  用戶@主機(jī)名:遠(yuǎn)端目錄   本地目錄
scp -r root@192.168.1.2:/456.txt ~

3、SCP無需輸入密碼傳輸文件 

在Linux環(huán)境下,兩臺主機(jī)之間傳輸文件一般使用scp命令,通常用scp命令通過ssh獲取對方linux主機(jī)文件的時候都需要輸入密碼確認(rèn)。

不過通過建立信任關(guān)系,可以實(shí)現(xiàn)不輸入密碼。

1)在其中一臺主機(jī)上執(zhí)行如下命令來生成配對密鑰: 

ssh-keygen -t rsa

按照提示操作,注意,不要輸入passphrase。提示信息如下

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
63:61:d2:ce:5f:e8:14:5c:56:2c:7b:08:71:41:a2:cc root@localhost.localdomain

2.)將 .ssh 目錄中的 id_rsa.pub 文件復(fù)制到另外一臺主機(jī)的 ~/.ssh/ 目錄中,并改名為 authorized_keys。

scp .ssh/id_rsa.pub 主機(jī)名:/root/.ssh/authorized_keys
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI