ssh信任分發公鑰

轉自:http://www.xxlinux.com/linux/article/network/app/20090907/17529.html

把你的本地主機用戶的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 文件名 [email protected]:遠程路徑

    (2)從遠程將文件拷回本地

    scp [email protected]:文件名 本地路徑

    複製目錄:

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

    scp -r 目錄名 [email protected]:遠程路徑

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

    scp -r [email protected]:目錄名 本地路徑。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章