# putty免密登入 (HW04) ### **1. 下載putty和puttygen(免安裝)** https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html 下載putt.exe ![](https://i.imgur.com/Tik3lMc.png) 下載puttygen.exe ![](https://i.imgur.com/oHivjnV.png) ### **2. 生成金鑰** 開啟puttygen,並按下Generate ![](https://i.imgur.com/suaZIw1.png) 移動滑鼠,生成金鑰 ![](https://i.imgur.com/YqPXhqO.png) 金鑰成功生成 ![](https://i.imgur.com/rV2f1vu.png) ### **3. 將公鑰複製到linux伺服器** 框選公鑰,並複製 ![](https://i.imgur.com/PkiQexo.png) 新增文字文件,儲存公鑰(無須副檔名) ![](https://i.imgur.com/Fk9js1t.png) ![](https://i.imgur.com/fPOD65s.png) 上傳公鑰至linux伺服器 `scp -P {port} {filename(本地端)} {username}@{ip}:{filename(伺服器端)}` ![](https://i.imgur.com/SvYnlS9.png) 開cmd,登入linux伺服器 `ssh {username}@{ip}` ![](https://i.imgur.com/TyBCAQF.png) 新增名為.ssh的目錄 `mkdir .ssh` ![](https://i.imgur.com/LHmoLVb.png) 將上傳的公鑰複製到.ssh的目錄下 `cp {filename} {(絕對)路徑}` ![](https://i.imgur.com/Xfd9TUM.png) * 公鑰的位址和檔名固定為~/.ssh/authorized_keys ### **4. 儲存私鑰** 按Save private key ![](https://i.imgur.com/WuR2iO1.png) 私鑰的副檔名為.ppk ![](https://i.imgur.com/BH71uR2.png) ### **5. putty自動登入設置** 開啟putty,在Connection/SSH/Auth/Gredentials裡,Private key file for authentication選取私鑰的檔案 ![](https://i.imgur.com/wvSu0MV.png) 在Connection/Data裡,Auto-login username輸入用戶名稱 ![](https://i.imgur.com/amO1Heb.png) 回到Session裡,輸入ip、port,並在Saved Sessions給免密登入帳號一個名稱,最後按Save ![](https://i.imgur.com/peEM3U3.png) ### **6. 登入** 按Open或雙擊免密登入帳號名稱 ![](https://i.imgur.com/fOFN7ux.png) * 學號: 1084955 ( stu1084955 ) * hostname : HW04 ### **參考資料** * http://blog.kejyun.com/2012/11/setting-ssh-key-to-achieve-non-password-login-on-ubuntu.html * https://crowsnest1217.com/%e5%ad%b8%e7%bf%92%e8%88%87%e5%88%86%e4%ba%ab/windows%e4%bd%bf%e7%94%a8ssh%e9%87%91%e9%91%b0%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5linux.html * https://www.puttylink.com/putty-login-without-password.html * https://xenby.com/b/220-%e6%95%99%e5%ad%b8-%e7%94%a2%e7%94%9fssh-key%e4%b8%a6%e4%b8%94%e9%80%8f%e9%81%8ekey%e9%80%b2%e8%a1%8c%e5%85%8d%e5%af%86%e7%a2%bc%e7%99%bb%e5%85%a5