Ubuntu – How to allow an ssh connection only over vpn

sshUbuntuufwvpn

I install OpenVPN on my server following this guide –> https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04

I also setup a firewall with ufw where I add rule to allow ssh connection only from my interal IP assign to me after the VPN is Active.

I cannot connect to my server with this configuration, with or without VPN. What can I do to configure the network to allow ssh connection ONLY over VPN tunnel?

Best Answer

You can control it using the ListenAddress directive available in your ssh daemon config file

Something Like

sudo nano /etc/ssh/sshd_config

Reach the line:

#ListenAddress 0.0.0.0

Uncomment if necessary, and edit it accordingly to your vpn configuration, something like:

ListenAddress 10.10.0.1

Restart the daemon

sudo service ssh restart

Check if it works

Keep in mind you can also tune your firewall rules to further restrict access to certain subnet / ports, in this case your vpn network

Hope it helps

Related Topic