###### tags: `大四上Linux系統管理` # SSH Key,免登入密碼進入伺服器 ## 下載putty 以及 putty generator >![](https://i.imgur.com/RGCZdZE.png) >**點選64-bit x86版本** ><https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html> ## 如何建立SSH Key?? >**需要開啟兩個終端機** >>**第一個終端機** >>![](https://i.imgur.com/o0R8Evr.png) >>![](https://i.imgur.com/2a1zb9k.png) >> >>**第二個終端機** >> >>**輸入ssh-keygen -t rsa -b 4096** >>![](https://i.imgur.com/sBdzdew.png) >> >>![](https://i.imgur.com/3G4Rewm.png) >> >>**Enter完成代表產生了public key和private key** >> > **到電腦找出public key和private key** >>![](https://i.imgur.com/PmEp6no.png) >> >>**id_rsa是private key 、 id_rsa.pub是public key** >> >>![](https://i.imgur.com/deh8i1O.png) ## 進入CMD SCP將公開金鑰傳到伺服器 >![](https://i.imgur.com/oFtg7Fa.png) >終端機輸入 scp C:\Users\acer\.ssh\id_rsa.pub 空白鍵s1082919@10.2.200.216:/home/s1082919/.ssh/伺服器金鑰名稱 伺服器金鑰名稱取名 ex: test.pub ## 授權剛剛的公開金鑰 ![](https://i.imgur.com/tvrSURf.png) >**登入伺服器 輸入以下指令** cat ~/.ssh/scp/伺服器金鑰名稱 >> ~/.ssh/authorized_keys >**再輸入** chmod 700 ~/.ssh/ chmod 600 ~/.ssh/* ## 開啟Putty key generator >**點選Load上傳剛剛創立的id_rsa private key** > >**轉成PPK檔案並儲存** > >![](https://i.imgur.com/ovin3zG.png) > >**點選generate產生ssh public key** > >**public key儲存成.pub** ## 開啟putty >**Browse Private key file for authentication** > >![](https://i.imgur.com/tR9il7a.png) > >**回到putty 輸入 使用者名稱@IP** >![](https://i.imgur.com/VUTT1AU.png) ## 完成ssh key免密碼登入