vi /etc/hosts.deny (拒否するIP/ホストを設定)
vi /etc/hosts.allow (許可するIP/ホストを設定)
今回は「許可するIPの設定なので
vi /etc/hosts.allow
↑でenterしたときに一時ファイルが残ってると
---------------------------------------------------------------
E325: ATTENTION
Found a swap file by the name "/etc/.hosts.allow.swp"
owned by: root dated: Fri Aug 9 11:13:55 2013
file name: /etc/hosts.allow
modified: YES
user name: root host name:***********
process ID: 12848
While opening file "/etc/hosts.allow"
dated: Tue Sep 11 15:17:14 2012
(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/hosts.allow"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.hosts.allow.swp"
to avoid this message.
"/etc/hosts.allow" 9L, 241C
Press ENTER or type command to continue
----------------------------------------------------------------
みたいなのが表示される。
「While opening file~」にその一時ファイルが作られた日時がある。
今回はほっといても問題無いのでそのまま強行w
そうすると、
------------------------------------------------------------------
# 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.
#
ALL: 許可されてるIP
ALL: 許可されてるIP
ALL: LOCAL
~
~
~
~
~
~
~
~
-----------------------------------------------------------------
となるので、コマンド「o」(小文字のオー)で
カーソルを「ALL: LOCAL」の下の行まで持っていく。
入力モードになっているようなら「Esc」でコマンドモードに切り替えて
sshd : 許可したいIP
で、最後にコマンド「:wq」で保存して終了。
cat -e /etc/hosts.allowで反映されているかを確認。
*参考URL*
SSHの接続制限設定
http://