Putty + public key authentication

每天收到朋友的Log,都會見到好多不同的人仕去Try 個server 的username 同 account。這個世界無聊人實在太多。所以我的sshd 要用iptables + public key authentication 去保護。

而如何在 Linux 去 Linux Server 中建立 public key authentication

我己經在 http://jktn.com/?p=32 談論過了。
而windows 如何在 putty 加入 Linux Server,則今天我才研究到。

1. 下載 puttygen.exe http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe

2. 運行 puttygen.exe
a. 選擇你要建立的鑰匙的類型
b. 按 Generate 去新增
c. 加入你要的comment
d. 輸入passphase

3. 將private key 存起來,並將public key 加入 server 的 ~/.ssh/authorized_keys 內。

4. 開啟putty,在Configuration 內
a. Connection 中 Auto Login Username 填入你要的 username
 b. Connection -> SSH -> AUTH 中 Private Key Authentication 中選擇你剛才存起的private key file 即可。 不過不要忘記鍵入server 名呀。 不過有一樣野都好重要,

在 /etc/ssh/sshd_config  

AllowUsers xxx yyy zzz 
DenyGroups root bin daemon sys adm tty disk lp mem kmem wheel floppy mail news uucp man games slocate utmp smmsp mysql rpc sshd shadow ftp nogroup console xcdwrite 
DenyUsers root bin daemon adm lp sync shutdown halt mail news uucp operator games ftp smmsp mysql rpc sshd nobody test guest user admin apache www wwwrun httpd irc
咁樣就可以等其他無謂人try 你個account 參考資料:
1. http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.html
2. http://phorum.vbird.org/viewtopic.php?t=20927

Comments

Popular Posts