SSH over VPN connection

2.9k views Asked by At

We have an AWS EC2 server that we've configured to be only accessible (via SSH) from within our office network. Obviously this isn't ideal for remote arrangements where someone has to connect to the EC2 instance and is working remotely outside the office such as during a business trip.

I've managed to set-up a VPN through PPTP and can connect to the office network (I have two local IP's one from wlan0 and one from ppp0) regardless of anywhere I am. However, when I SSH to the EC2 instance, it's still rejecting me most likely because it sees that I'm still trying to ssh from outside the network.

I think I'm missing something very important. What do you think, what am I missing to to get the ssh to use the vpn connection rather than one in wlan/eth?

I'm starting to think this isn't possible so kindly let me know. My other option is to ssh to a machine within the office network and then use that machine to ssh to the EC2 instance but I've been hesistant to do that as it seems excessive.

2

There are 2 answers

0
Barak On

Just having a VPN to your office does not mean all traffic from your machine will go through the VPN - that depends on how you configure the VPN.

You can SSH from your machine to an office machine, and from there ssh to EC2 - that should work.

Alternatively, configure your system to route traffic for the ec2 instance through the VPN connection - doing this depends on your specific VPN configuration.

0
techNlogic On

Find your gateway through which you want to connect to your ec2-instance. For Linux systems, route -n will show you the routing table. Now add the route sudo route add -host gw