> For the complete documentation index, see [llms.txt](https://kb.asyraf.my/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.asyraf.my/linux-guide/lockdown-ssh.md).

# Lockdown SSH

How to lockdown SSH access

If you are using iptables for your machine Firewall.

Below script might help to lock down SSH access which only allow specific IP to connect via SSH.

```
##########################
# LOCK DOWN
##########################
for IP in 111.111.111.111 222.222.222.222 333.333.333.333 444.444.444.444/27 ; do
/sbin/iptables -A INPUT -p tcp -s $IP –dport (SSH PORT)-j ACCEPT
/sbin/iptables -A OUTPUT -p tcp -d $IP –sport (SSH PORT)-j ACCEPT
done
iptables -A INPUT -p tcp –dport (SSH PORT) -j DROP
iptables -A OUTPUT -p tcp –sport (SSH PORT)-j DROP

#####################
```

Make sure to change (SSH PORT) to your SSH Port.

Hope this would be useful.
