How can allow an ssh connection only over vpn
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 videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
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?
-
Admin over 2 yearsFor ufw, see also cyberciti.biz/faq/…
-