少しセキュリティ

少しだけセキュリティ対策
vi /etc/ssh/sshd_config
AllowUsers xxx
ログインできるユーザを限定する。記載しなければ,rootもログインできなくなる。
# systemctl restart sshd
ログインの失敗歴の表示(/var/log/btmp)
# lastb

他のシステムにsshでログインするために、pacman -S openssh
ssh user@xx.xx.xx.xxで、接続できる。

fail2banも設定
# pacman -S fail2ban
# cd /etc/fail2ban
# cp jail.conf jail.local
# vi jail.local
[sshd]のセクションにenabled = trueを追加
# systemctl start fail2ban
# systemctl enable fail2ban
# fail2ban-client status
# tail -20 /var/log/fail2ban.log
# iptabkes -nvL

確認してみると、sshdへの不正アクセスは、Conohaに比較して、Altusは非常に多い。
テストしていると、自分自身のIPが禁止されてしまった。
# fail2ban-client status sshd
解除するには
# fail2ban-client reload –unban sshd
または
# fail2ban-client unban xxx.xxx.xxx.xxx
# fail2ban-client unban –all
解除したIPの数が返される。

fail2banでセキュリティ。
/etc/fail2ban/jail.conf のasteriskはメール報告がついているので、actionのメールはコメントにしておく。
defaultのmaxretry=10となっているので、個別のセクションで適正な値を設定しておく。
applicationのprofileを作成したら、 fail2ban-regex log_file filter_nameで matchしていることと、日時を認識できているかを確認する。filter_nameにはパスを含める必要はない。

コメント