scp在Linux主機之間複製不用輸入密碼

來源:互聯網
上載者:User

把你的本地主機使用者的ssh公匙檔案複製到遠程主機使用者的~/.ssh/authorized_keys檔案中,假設本地主機linux(10.1.1.1),遠程主機linux(10.1.1.2)

一,在linux100主機裡的使用者

運行

#ssh-keygen -t rsa

結果如下

Generating public/private rsa key pair.

Enter file in which to save the key (/home/.username/ssh/id_rsa):#斷行符號

Enter passphrase (empty for no passphrase):#斷行符號

Enter same passphrase again:#斷行符號

Your identification has been saved in /home/.username /.ssh/id_rsa.

Your public key has been saved in /home/.username /.ssh/id_rsa.pub.

The key fingerprint is:

38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost

Generating RSA keys:

Key generation complete.

會在使用者目錄~/.ssh/產生兩個檔案,id_rsa,id_rsa.pub

二,把linux(10.1.1.1)主機上的id_rsa.pub檔案拷貝到linux(10.1.1.2)主機的root使用者主目錄下的.ssh目錄下,並且改名為authorized_keys

即:

/root/.ssh/authorized_keys

這樣在linux100主機上使用scp命令複製檔案到linux(10.1.1.2)上將不提示輸入密碼了,直接複製了。反之亦然!

三,複製檔案或目錄命令:

複製檔案:

(1)將本地檔案拷貝到遠程

scp 檔案名稱  user@10.1.1.2:遠程路徑

(2)從遠程將檔案拷回本地

scp  user@10.1.1.2:檔案名稱 本地路徑

複製目錄:

(1)將本地目錄拷貝到遠程

scp -r 目錄名  user@10.1.1.2:遠程路徑

(2)從遠程將目錄拷回本地

scp -r  user@10.1.1.2:目錄名 本地路徑。

 

原文連結:http://www.memoon.cn/wschool/server/linux/20090905/16755.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.