亞波治

특정 IP만 SSH 접속 허용하기

서버관리시 Root를 사용하기 위해 특정 IP만 SSH에 접속 가능 하도록 아래 방법으로 수정해 보았습니다.

 

/etc/hosts.allow 수정

#
# 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: 113.157.124.168, 135.79.246.

→ 113.157.124.168와 135.79.246.XXX 대역을 허용
위와 같이 한줄에 적어도 되지만, 아이피가 많아지면 관리가 어렵다. 아래와 같이 여러줄로 나누어 적어도 된다.
sshd: 113.157.124.168
sshd: 135.79.246.


/etc/hosts.deny 수정

#
# 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

ALL 적용시 나머지는 모두 ssh 접근 불가 sshd 재시작 해야 정상 적용된다.

# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

 

출처 : http://www.nanoomi.org/bbs/board.php?bo_table=03_2&wr_id=5&page=2 

|

댓글 2개

host 파일 수정에는 리스타트가 필요없습니다.
sshd 데몬이 읽고 막는게 아니라서요.
그런가요? 뭔가 작업하면 리스타트가 버릇이 되어서요....^^
댓글을 작성하시려면 로그인이 필요합니다.

서버관리자 모임 게시판 입니다.

+
제목 글쓴이 날짜 조회
15-12-05 조회 3,141
15-12-04 조회 1,781
15-12-03 조회 2,380
15-12-03 조회 2,519
15-12-03 조회 3,781
15-12-02 조회 3,675
15-12-01 조회 3,676
15-12-01 조회 3,425
15-12-01 조회 1,634
15-11-27 조회 3,200
15-11-27 조회 2,509
15-11-25 조회 2,040
15-11-25 조회 3,707
15-11-20 조회 3,100
15-11-20 조회 3,550
15-11-20 조회 2,259
15-11-20 조회 2,824
15-11-19 조회 2,895
15-11-19 조회 2,635
15-11-18 조회 2,966
15-11-17 조회 1,967
15-11-17 조회 3,344
15-11-17 조회 2,087
15-11-16 조회 2,336
15-11-16 조회 4,437
15-11-16 조회 1,609
15-11-15 조회 2,728
15-11-15 조회 2,125
15-11-15 조회 2,220
15-11-13 조회 2,620