環境:CentOS6.4 ×86_64
・SSH
sshのポート番号変更とPassword認証不可とRootlogin不可に設定
#vi /etc/ssh/sshd_configPort 22 -> Port 任意の番号(10022)
PasswordAuthentication yes -> no
PermitRootLogin no -> yes
#service sshd restart
sshのポート番号変更とPassword認証不可とRootlogin不可に設定
#vi /etc/ssh/sshd_configPort 22 -> Port 任意の番号(10022)
PasswordAuthentication yes -> no
PermitRootLogin no -> yes
#service sshd restart
authorized_keysを設定
$mkdir .ssh
$chmod 700 .ssh
$vi .ssh/authorized_keys
クライアントで作成したid_rsa.pubを転送して中身をコピペ
$chmod 600 .ssh/authorized_keys
$mkdir .ssh
$chmod 700 .ssh
$vi .ssh/authorized_keys
クライアントで作成したid_rsa.pubを転送して中身をコピペ
$chmod 600 .ssh/authorized_keys
# フィルタリングルールを消去する
/sbin/iptables -F
/sbin/iptables -F
# デフォルトポリシーを設定(最初にすべてのポリシーをDROPに設定)
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
# ループバックを許可する
/sbin/iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
/sbin/iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
/sbin/iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
/sbin/iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
# プライベートアドレスが使われているパケットを破棄
/sbin/iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 172.16.0.0/12 -j DROP
/sbin/iptables -A INPUT -i eth0 -s 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 10.0.0.0/8 -j DROP
/sbin/iptables -A INPUT -i eth0 -s 172.16.0.0/12 -j DROP
/sbin/iptables -A INPUT -i eth0 -d 172.16.0.0/12 -j DROP
# Ping of Death対策
/sbin/iptables -A INPUT -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
/sbin/iptables -A INPUT -p icmp –icmp-type echo-request -m limit –limit 1/s -j ACCEPT
# 設定が適用されているか確認
/sbin/iptables -L
/sbin/iptables -L
iptablesの確認
#iptables -L Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all — localhost localhost
DROP all — 10.0.0.0/8 anywhere
DROP all — anywhere 10.0.0.0/8
DROP all — 172.16.0.0/12 anywhere
DROP all — anywhere 172.16.0.0/12
ACCEPT tcp — anywhere anywhere state NEW tcp dpt:10022
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp — anywhere anywhere icmp echo-request limit: avg 1/sec burst 5
#iptables -L Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all — localhost localhost
DROP all — 10.0.0.0/8 anywhere
DROP all — anywhere 10.0.0.0/8
DROP all — 172.16.0.0/12 anywhere
DROP all — anywhere 172.16.0.0/12
ACCEPT tcp — anywhere anywhere state NEW tcp dpt:10022
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp — anywhere anywhere icmp echo-request limit: avg 1/sec burst 5
※iptablesのfilterテーブルは、
chainがINPUT,OUTPUT,FORWARDの3つあって
それぞれに全体のポリシー(ACCEPT/DROP)を指定して
必要があれば個別にACCEPT/DROPをする。
chainがINPUT,OUTPUT,FORWARDの3つあって
それぞれに全体のポリシー(ACCEPT/DROP)を指定して
必要があれば個別にACCEPT/DROPをする。
・selinux
一時設定(Enforcing:有効/Permissive:警告のみ/disabled:無効)
#getenforce
Enforcing
#setenforce 0
# getenforce
Permissive
0 件のコメント:
コメントを投稿