[CentOS5][SSH] IPアドレスによる接続制限を行うには

 接続元IPアドレスが限定されているのなら、是非この設定を行っておきましょう。

 ただし、当然ながら、IPアドレスが変わると接続できなくなりますのでご注意を。特に、マンション住まいで光ファイバを利用している場合、一見固定IPアドレスのようですがたまに変わる場合もあります。固定IPアドレス付与サービスを導入している等、固定IPアドレスであることが保証される場合のみ実施するのがよいでしょう。

 ちなみに、例ではSSHだけ書いていますが、FTP等でも利用できます。

hosts.allowを編集する

# vi /etc/hosts.allow

 接続許可するIPアドレスを「sshd : IPアドレス」の形式で追記します。

#
# hosts.allow	This file describes the names of the hosts which are
#		allowed to use the local INET services, as decided
#		by the '/usr/sbin/tcpd' server.
#

sshd : 123.123.123.123               # Example
sshd : 210.150.83.8/255.255.255.248  # WebARENA

hosts.denyを編集する

# vi /etc/hosts.deny

 「sshd:ALL」を追記します。これを書いておかないと、全てのIPアドレスから接続可能なままです。

#
# hosts.deny	This file describes the names of the hosts which are
#		*not* allowed to use the local INET services, as decided
#		by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!

sshd:ALL
Page 1 of 8012345»102030...Last »