Limiting SSH Access to Specific IP Addresses
Log into each server via SSH and su to root.
- Edit /etc/hosts.allow
- Open a new line before:
# Start by allowing everything (this prevents the rest of the file.
# from working, so remove it when you need protection).
# The rules here work on a "First match wins" basis.
ALL : ALL : allow
and add the following:
sshd: ALL : deny
- For each IP address you want to allow, add the following to /etc/hosts.allow above the line sshd : ALL : deny:
sshd : xxx.xxx.xxx.xxx : allow
sshd : xxx.xxx.xxx.xxx : allow
sshd: ALL : deny
- Save the file
IMPORTANT: Before you log off your current SSH session, try to open another SSH
session to the machine you just made these settings on. If you cannot get into the
system, then in your already open SSH session, then comment out the lines you added.

|