EPguy

ssh 특정 IP의 접속만 허용하는 방법 본문

개발/기타

ssh 특정 IP의 접속만 허용하는 방법

EPguy 2023. 9. 26. 15:29

접속 허용할 IP 추가하기

vi /etc/hosts.allow

#
# Example:    ALL: LOCAL @some_netgroup
#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
sshd: 접속 허용할 IP
sshd: 192.168.1.1
sshd: 192.168.1.2

sshd: ALL 추가하여 나머지는 접근 불가하게 만들기

vi /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