目標:system1透過ssh鏈接到system2電腦vim
步驟以下:windows
# ssh-keygen -t rsa
Enter file in which to save the key (~/.ssh/id_rsa): Created directory '~/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in ~/.ssh/id_rsa. Your public key has been saved in ~/.ssh/id_rsa.pub. The key fingerprint is: 1c:fe:8d:10:b5:32:09:95:51:48:df:45:ef:74:5d:dc henry@db0222da7529 The key's randomart image is: +--[ RSA 2048]----+ | .o+=o .o.o| | .o+ o . .E| | * o . =| | o = o.| | S .| | o o | | o . | | | | | +-----------------+
ssh-keygen的參數說明:服務器
-t type
Specifies the type of key to create. The possible values are
``rsa1'' for protocol version 1 and ``dsa'', ``ecdsa'' or ``rsa''
for protocol version 2.
# cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
注意: 用putty自帶的PUTTYGEN.EXE生成會不兼容OpenSSH,從而會致使登陸時出現server refused our key錯誤app
作法: 把private key(id_rsa)給拷貝出來,我是用vim或cat來開啓id_rsa文件而後用鼠標按右鍵拷到windows下的剪貼板, 存到一個文本給PUTTYGEN.EXE File/Load private key使用. 接着點擊Save private key, 此檔案等下要用.dom
1.開啓putty.exe, 設定Connection/data/Auto-login username, 這裏我是用root來登入ssh
2.SSH/Auth/Private key file for authentication:點擊Browser選擇到你保存私鑰(.pkk)的文件, 就是 Save private key 的那個檔案.ide