看板FreeBSD
标 题Re: [问题] FreeBSD如何防止别人try密码呢?
发信站城区夜未眠 (Wed Sep 20 21:15:54 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.nsysu!news.isu!NightlessBBS
※ 引述《[email protected] (好小孩)》之铭言:
> ※ 引述《drlai (苏打)》之铭言:
> : 最近架了一个小型Server
> : 但我发现security run output中有纪录一连串的try密码纪录
> : FreeBSD中能否设定
> : 让某个IP输入错误3次以上直接block该IP位置呢?
> : 或是各位有其他比较好的防范方式?
> : 每天login failure纪录都是一大串
> : 但实际上在try login的只有少数几个IP
> : 感谢m(_ _)m
> 用 ssh key 来认证
> 请参考 ssh manual
> 或是 sshd 换 port
以前的笔记
1) 废除密码登录, 强迫使用 RSA 验证(假设用 ssh 登入帐号为 kevinblue )
# vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
有这行如果没key就会自动断线
# /usr/local/etc/rc.d/sshd restart
接下来切换成你的帐号的家目录下
# cd /home/kevinblue
$ mkdir .ssh
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 644 ~/.ssh/authorized_keys
--------------------------------------------------
转往 client 端(freebsd):
$ ssh-keygen -t rsa
(按三下 enter 完成﹔不需设密码,除非您会用 ssh-agent 。)
$ scp ~/.ssh/id_rsa.pub
[email protected]:id_rsa.pub
(若是 windows client, 可用 puttygen.exe 产生 public key,
然後复制到 server 端後修改之, 使其内容成为单一一行.)
--------------------------------------------------
如果你是 windiws 可以用 puttygen 产生 rsa_key再 export 成 openssh 格式便可
---------------------------------------------------
回到 server 端:
$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
$ rm ~/id_rsa.pub
--
◤◤◤◣
极端怕麻烦的家伙为了轻松解决问题所想出来的创意与巧思 ˙█
˙█
────────────────────────── ████
带动了人类的发明和进步 ◥██◤
M█ ψKidult73
--
█◣██ ██ ██ ██ █ ██ ██ ██ * ● . ' ▃▃
██ █
▅ ██ █ █
█▆ █▆ █▆ ' * . :: : :: : :
█◥ █ ██ ██ █ █▆ █▆ ▆█ ▆█ 城区夜未眠 : :: :: : ::
Origin:东吴资科城区夜未眠(nightless.twbbs.org)▊▋▎ [FROM:125.228.29.83]
※ 编辑: kevinblue 来自: 125.228.29.83 (09/20 21:19)