Im setting up a web server on 18.04 and I want to be able to block all ip's except my public ip from accessing ssh (22) on the UFW. Thanks for your help!


This should do the trick assuming your public ip is

sudo ufw allow from to any port 22

Please refer to man ufw for more info.

I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.