Question

How to limit SSH-Access to IP

Hi there

I’m using Ubuntu 14x and due to security, I’d like to limit ssh connections to just my VPN (OpenVPN) address.

How to proceed? I found many ways, but AllowUsers root@ip didn’t do the job.

Thanks, Sullivan


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Thank you very much.

That means

iptables -I INPUT -p tcp ! -s 178.000.000.000 --dport 22 -j DROP

will protect my server on port 22 and ssh will only be allowed through this ip?

Best

This comment has been deleted

Configure your Firewall, (iptables or ufw) to reject connections on your SSH Port unless from that specific IP Address. Using something like the below: iptables -I INPUT -p tcp ! -s <permittedIP> -j DROP

ref: http://unix.stackexchange.com/questions/145929/how-to-ensure-ssh-port-is-only-open-to-a-specific-ip-address