歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> linux ssh密匙登陸

linux ssh密匙登陸

日期:2017/3/1 14:42:49   编辑:關於Linux
  1. 安裝OpenSSh,一般linux 系統都自帶有

    [root@sqzr ~]# ssh-keygen -b 1024 -t rsa
    Generating public/private rsa key pair. #提示正在生成rsa密鑰對
    Enter file in which to save the key (/root/.ssh/id_dsa): #詢問公鑰和私鑰存放的位置,回車用默認位置即可
    Enter passphrase (empty for no passphrase): #詢問輸入私鑰密語,輸入密語
    Enter same passphrase again: #再次提示輸入密語確認
    Your identification has been saved in /root/.ssh/id_dsa. #提示公鑰和私鑰已經存放在/root/.ssh/目錄下
    Your public key has been saved in /root/.ssh/id_dsa.pub.
    The key fingerprint is:
    x6:68:xx:93:98:8x:87:95:7x:2x:4x:x9:81:xx:56:94 root@server #提示key的指紋

  2. 生成好後,將/root/.ssh/id_dsa文件通過WinSCP保存到本地
  3. 下載puttygen.exe(下載地址見文章末),將保存到本地的id_dsa導入,並輸入生成的時候輸入的私匙密語

    1

  4. 導入成功後,保存公匙,並將公匙的內容寫到~/.ssh/authorized_keys

    2

  5. 保存後綴名為ppk的私匙,關閉linux密碼登錄(只允許私匙登錄)

    修改/etc/ssh/sshd_config 文件
    將PasswordAuthentication yes 修改成 PasswordAuthentication no,並且重啟ssh
    在putty導入私匙
    3

    再次登錄如果不用私匙連輸入密碼的幾乎都沒有,導入私匙後,登錄的時候只需要輸入私匙的口令就ok,就算私匙文件被別人拿到也沒事,別人無法知道是哪台服務器的,也無法得到私匙口令
    4

    工具下載地址:

    puttygen官方下載鏈接:http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe
    putty官方下載鏈接:http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

Copyright © Linux教程網 All Rights Reserved