FreeBSD12インストール後の初期設定

FreeBSD12はサポート期限切れのバージョンなので注意
コロデのメモ帳として使用していたWikiは、事情により閉鎖したので移植
移植の為、古い情報になりますが基本的な部分は使えると思います

tmp自動削除を追加

SSH設定

・SSH1は廃止されたのでProtocol 2は不要

# ee /etc/ssh/sshd_config
PermitRootLogin no      (rootログイン拒否、コメントアウト外す)
PasswordAuthentication yes (パスワード認証ログイン許可、変更)
PermitEmptyPasswords no   (空のパスワードを禁止、コメントアウト外す)
AllowUsers user_name    (user_nameのみログイン許可、追加)
# /etc/rc.d/sshd restart

group設定

・user_nameをwheelに所属させる (user_nameは追加したログインID)

# ee /etc/group
wheel:*:0:root,user_name

セキュリティアップデート

# freebsd-update fetch
# freebsd-update install

portsアップデート

初回
# portsnap fetch
# portsnap extract
# portsnap update
2回目から
# portsnap fetch
# portsnap update

hosts.allow設定

・基本的には閉じて必要になったら開ける
 デフォルトのallowは全てコメントアウトし、denyの行を追加
・プライベートIPは全開放してるけど、SSHのみとかに分けたほうが良い
 「sshd : 192.168.0. : allow」 等
・外部からの接続の場合、jpだけだとログイン出来ない場合もあるので注意
・下の方の文章の所は、アクセス者への返答処理なのですべてコメントアウト

# ee /etc/hosts.allow
#ALL : ALL : allow
ALL : 192.168.0. : allow
sshd : .jp : allow
sshd : ALL :deny
#sendmail : ALL : allow
sendmail : ALL : deny
#exim : ALL : allow
exim : ALL : deny
#ftpd : ALL : allow
ftpd : ALL : deny
ALL : ALL : deny

firewallとblacklist設定

・ipfwを使用
・firewall.confの記述については他のサイトを参考
・firewall_loggingで/var/log/securityにログが出る
・blacklistd_flags=“-r”
 -r、システムを再起動しても再度ルールを適用してブロックを開始
 -f、再起動時に消去

# ee /etc/rc.conf
#sshd
sshd_enable="YES"
sshd_flags="-o UseBlacklist=yes"
#blacklist
blacklistd_enable="YES"
blacklistd_flags="-r"
#firewall
firewall_enable="YES"
firewall_type="/etc/firewall.conf"
firewall_logging="YES"

・ファイルを作らないとipfwと連携されないので、touchで作る

# touch /etc/ipfw-blacklist.rc
# less /etc/blacklistd.conf
# /etc/rc.d/ipfw start
# /etc/rc.d/blacklistd start
確認
# ipfw -a list
# ps awux | grep blacklistd
# blacklistctl dump -ar

ntp設定

# ee /etc/ntp.conf
pool 0.freebsd.pool.ntp.org iburst
pool ntp.jst.mfeed.ad.jp iburst
# ee /etc/rc.conf
ntpd_enable="YES"

不要プロセスの停止 (ttyv)

・仮想コンソールの数が多いので減らす、ttyv1~ttyv7をoff
 基本的にはリモート接続で作業するので問題無し

# ee /etc/ttys
onifexists secure
    ↓
off secure
# kill -HUP 1

tmp自動削除

・/etc/periodic.confに追記、無い場合は作成

# ee /etc/periodic.conf
daily_clean_tmps_enable="YES"

デフォルトでは3日前のファイルが削除対象
日数を変えたい場合以下を追記して数値を変更

daily_clean_tmps_days="10"

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA