LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Reach ssh server when connected to VPN (https://www.linuxquestions.org/questions/linux-networking-3/reach-ssh-server-when-connected-to-vpn-4175500422/)

atengesdal 04-03-2014 03:26 AM

Reach ssh server when connected to VPN
 
Hi,

I have an Ubuntu 12.04 server connected to ISP through ETH interface, and is always activated on OpenVPN (Privateinternetaccess). I would like to reach this server through ssh but can't really understand how to do this step-by-step. First, what needs to be done on the modem that the server (and rest of the network is connected to)? itself? It's a zyxel, assuming this needs to be set up with port forwarding?
Until now I have just used teamviewer to access my server when out of the house :-)
After this, then what? My servers' external IP address has now of course changed due to VPN, so how can I reach it again?

Thanks,

Arve

cliffordw 04-04-2014 12:35 AM

Hi,

Let's look at this without the VPN component first. To SSH into your server, you're on the right track. There are 2 steps, namely:

* Configure the router for forward traffic for port 22 (SSH) to your server. I don't know the ZyXEL routers to advise on how to do this, but it's fairly straight forward on most routers. You might also find details at http://portforward.com/english/route...warding/ZyXEL/.
* To find the IP address so you can connect to it from outside even if it has changed, you can register it with a dynamic DNS service. Most routers can do the DNS updates for you automatically when the IP changes. It looks like ZyXEL can do the same - see http://help.zyxel.com/documents/webh..._WAN_DDNS.html.

If we add the VPN into the equation, the same principals apply, but some things work a little differently as you're effectively moving the end points of the connection. You didn't supply much information on the OpenVPN setup, though. Could you please elaborate on this a little? Some questions:

* Is the VPN connection established by your router or by your server?
* Where is the other end of the VPN connection - a server you manage, a public VPN service, your office, etc?

This will influence how you do the port forwarding or routing, and where/how you run a suitable DDNS service.

Regards,

Clifford

cliffordw 04-04-2014 01:00 AM

Some additional info on Dynamic DNS on Linux: http://www.linuxhomenetworking.com/w..._:_Dynamic_DNS

atengesdal 04-04-2014 04:48 PM

Hi Clifford!
Thanks a lot for your response, appreciated!
After your response, I have done the following:
-Found my external IP address, without VPN
-Registered DDNS and activated host on my server
-Port forwarding in my router to my internal IP address on my server
-After this I am now able to ssh into my server using
xxxx@mynewddnsaddress.xxx; this is without VPN activated, so far so good :-)


To answer your questions:
If we add the VPN into the equation, the same principals apply, but some things work a little differently as you're effectively moving the end points of the connection. You didn't supply much information on the OpenVPN setup, though. Could you please elaborate on this a little? Some questions:

* Is the VPN connection established by your router or by your server?
This is done through my server, only
* Where is the other end of the VPN connection - a server you manage, a public VPN service, your office, etc?
www.privateinternetaccess.com; iaw public VPN service
This will influence how you do the port forwarding or routing, and where/how you run a suitable DDNS service.

This is where I can't understand how this is supposed to work, how can I link my ddns to an IP nobody knows?

Thanks,

Arve

atengesdal 04-04-2014 05:10 PM

Quote:

Originally Posted by atengesdal (Post 5146806)
Hi Clifford!
Thanks a lot for your response, appreciated!
After your response, I have done the following:
-Found my external IP address, without VPN
-Registered DDNS and activated host on my server
-Port forwarding in my router to my internal IP address on my server
-After this I am now able to ssh into my server using
xxxx@mynewddnsaddress.xxx; this is without VPN activated, so far so good :-)


To answer your questions:
If we add the VPN into the equation, the same principals apply, but some things work a little differently as you're effectively moving the end points of the connection. You didn't supply much information on the OpenVPN setup, though. Could you please elaborate on this a little? Some questions:

* Is the VPN connection established by your router or by your server?
This is done through my server, only
* Where is the other end of the VPN connection - a server you manage, a public VPN service, your office, etc?
www.privateinternetaccess.com; iaw public VPN service
This will influence how you do the port forwarding or routing, and where/how you run a suitable DDNS service.

This is where I can't understand how this is supposed to work, how can I link my ddns to an IP nobody knows?

Thanks,

Arve

Funny thing is, now it seems OK, I can reach my server through DDNS service, but when my server asks me for the password it returns back as illegal. Any idea? Is there a mismatch between my RSD* keystring or whatever it is called :-) and my laptop? It works fine without VPN, but won't accept my ssh when server is connected to VPN..

Thanks,

Arve

atengesdal 04-04-2014 05:21 PM

Quote:

Originally Posted by atengesdal (Post 5146811)
Funny thing is, now it seems OK, I can reach my server through DDNS service, but when my server asks me for the password it returns back as illegal. Any idea? Is there a mismatch between my RSD* keystring or whatever it is called :-) and my laptop? It works fine without VPN, but won't accept my ssh when server is connected to VPN..

Thanks,

Arve

And this is the output:
Apr 4 23:57:20 ENGWINST sshd[13597]: Accepted password for root from 192.168.10
.170 port 34430 ssh2
Apr 4 23:57:20 ENGWINST sshd[13597]: pam_unix(sshd:session): session opened for
user root by (uid=0)
Apr 5 00:00:01 ENGWINST CRON[13803]: pam_unix(cron:session): session opened for
user root by (uid=0)
Apr 5 00:00:01 ENGWINST CRON[13803]: pam_unix(cron:session): session closed for
user root
Apr 5 00:02:26 ENGWINST sshd[13597]: Received disconnect from 192.168.10.170: 1
1: disconnected by user

and the password is correct is correct..


All times are GMT -5. The time now is 07:36 PM.