Jump to content
Not connected, Your IP: 18.117.156.84
Cloud9team

AirVPN with OpenVPN on Ubuntu VPS SSH and VPN HELP!

Recommended Posts

Hello. 

Today i have setup my VPS on VULTR using an Ubuntu 16:06 x64 setup.
I have followed all the installation guides to setup and run AirVPN via openvpn via command line. 

I log into my VPS via ssh. I use the IP address and Password for my VPS. 
VPS IP = 1.2.3.4 and Password...


Once logged in, i run the command: /etc/openvpn/my_ovpn_UDP-443.ovpn
This runs the vpn and activates it. Once this has completed i am kicked out of my terminal ssh connection. 

Upon trying to connect back to my vps using my main IP 1.2.3.4 and Password, i am unable to connect, i assume this this because the vpn is running and now using a different IP. ?

What i would like to know is. 
How can i use ssh and run the vpn on my vps. The commands are what i do not know?

I have read through the guides below:
Config Generator: https://airvpn.org/generator/
SSH AirVPN: https://airvpn.org/ssh/

On the SSH guide, i have followed all the steps but i am stuck on the last part.

I do not know what to enter into the command line. (Even if this is correct)

So i have
> my .ovpn file
> my .sh file
> my sshtunnel.key

But i do not know what to do with them go get the vpn to run and keep my ssh alive. 

Advice from AirVPN Support was:

Just execute the *.sh file from one terminal.
Example: /etc/openvpn/nameofshfile.sh (This does run the file)

 

Then, from a second terminal, after ssh has completed connection, run OpenVPN as root:

 

/etc/openvpn openvpn/nameofovpnfile.ovpn (this does run the vpn)

 

Well, once this is done i again loose connection to my VPS via the original 1.2.3.4 IP address. 

 

 

 

The ultimate aim is to run AirVPN / openvpn via command in my terminal that i have logged into via ssh. 

I want to be able to activate the VPN and continue to keep the SSH terminal open and also log back into SSH using the original VPS IP and password.

Any help would be very much appreciated in aiding me to get this running. 

Many Thanks for your time. 
Regards

Share this post


Link to post

Hi,

 

In your ovpn file, add this :

script-security 2
up /etc/openvpn/nameofothershfile.sh

In another sh file, add this :

#!/bin/sh
/sbin/ip route add <your_isp_ip_address>/32 dev <interface>

In a terminal :

chmod +x /etc/openvpn/nameofothershfile.sh

NOTE: <interface> should be replaced with the name of your Ethernet card name.

Obviously everything should be run as root.

 

Voilà!

Share this post


Link to post

Hay, 

Ok i can confirm that the VPN is running and i CAN log in now via SSH. 

Looking at the IP Routing, it looks like the VPN is being routed through the VPS rather than through the VPN. 

 

I am trying to run a program on the VPS using the VPN IP. 
Its currently Banning my IP which i believe is the IP from the VPS. 

 

When trying to run the .ovpn, this is at the end of the log:

```debug1: Local connections to LOCALHOST:1412 forwarded to remote address 127.0.0.1:2018

debug1: Local forwarding listening on ::1 port 1412.

bind: Address already in use

debug1: Local forwarding listening on 127.0.0.1 port 1412.

bind: Address already in use

channel_setup_fwd_listener_tcpip: cannot listen to port: 1412

Could not request local forwarding.

debug1: Requesting no-more-sessions@openssh.com

debug1: Entering interactive session.

debug1: pledge: network

debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0

debug1: Remote: PTY allocation disabled.

debug1: Remote: X11 forwarding disabled.

debug1: Remote: Forced command.```

 

 

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         45.63.107.1     0.0.0.0         UG    0      0        0 ens3

10.4.0.0        0.0.0.0         255.255.0.0     U     0      0        0 tun0

45.63.106.0     0.0.0.0         255.255.254.0   U     0      0        0 ens3

45.63.107.247   0.0.0.0         255.255.255.255 UH    0      0        0 ens3

169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 ens3

207.246.112.0   0.0.0.0         255.255.254.0   U     0      0        0 ens3

Share this post


Link to post

Yes openvpn will add a route in your system so that you can get access to your server through the "normal" connection.

Share this post


Link to post

Yes openvpn will add a route in your system so that you can get access to your server through the "normal" connection.

 

Hi Nick. 

Thanks, it looks like that it what its doing thanks to your code, however, it will not connect to the VPN.

I edited my post with the below info.

 

channel_setup_fwd_listener_tcpip: cannot listen to port: 1412

Could not request local forwarding.

 

Not sure why this would be

Share this post


Link to post

Looking at the IP Routing, it looks like the VPN is being routed through the VPS rather than through the VPN. 

 

Type

curl ipinfo.io/ip

if it displays your VPN's IP address, then everything's ok.

 

```debug1: Local connections to LOCALHOST:1412 forwarded to remote address 127.0.0.1:2018

debug1: Local forwarding listening on ::1 port 1412.

bind: Address already in use

debug1: Local forwarding listening on 127.0.0.1 port 1412.

bind: Address already in use

channel_setup_fwd_listener_tcpip: cannot listen to port: 1412

Could not request local forwarding.

debug1: Requesting no-more-sessions@openssh.com

debug1: Entering interactive session.

debug1: pledge: network

debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0

debug1: Remote: PTY allocation disabled.

debug1: Remote: X11 forwarding disabled.

debug1: Remote: Forced command.```

Are you trying to forward a port through SSH ?

Share this post


Link to post

curl ipinfo.io/ip

 

Does indeed show the IP of the VPN..

 

 

I can see what the duplicate connection is:

This is the .sh file

```

 

#!/bin/bash

# --------------------------------------------------------

# Air VPN | https://airvpn.org | Sunday 4th of March 2018 07:45:35 PM

# SSH Client Configuration, Linux/OSX

# AirVPN_US-Atlanta-Georgia_Sagittarius_SSH-22

# --------------------------------------------------------

 

#!/bin/sh

/sbin/ip route add 45.63.107.248/32 dev ens3

 

chmod 600 sshtunnel.key

while :

do

echo ""; echo "AirVPN SSH Tunnel"

ssh -i sshtunnel.key -L 1412:127.0.0.1:2018 sshtunnel@108.177.134.74 -p 22 -N -$

read -t 5 -p "Retry? (or wait 5 sec for Y)" yn

if [[ $yn == "n" || $yn == "N" ]]; then break; fi

done```

Share this post


Link to post

All i want to do is run the VPN and be able to connect via SSH using the main IP but when logged in via the main IP and commands run in that terminal are run through the VPN

 

Unless, there is a way to Ssh using the VPN login somehow of which i do not know how to do.

Share this post


Link to post

I'm not well versed in openvpn over SSH but if the command I gave you replies with the VPN's IP address, it must be working.

However why are you using this type of connection ? Is your VPS provider throttling VPNs ?

Share this post


Link to post

I'm not well versed in openvpn over SSH but if the command I gave you replies with the VPN's IP address, it must be working.

However why are you using this type of connection ? Is your VPS provider throttling VPNs ?

 

I am trying to run a program that my IP on the VPN is banned (not allowed to connect). 

I need to use a VPN with an IP from a specific US State. 

Share this post


Link to post

 

I'm not well versed in openvpn over SSH but if the command I gave you replies with the VPN's IP address, it must be working.

However why are you using this type of connection ? Is your VPS provider throttling VPNs ?

I am trying to run a program that my IP on the VPN is banned (not allowed to connect). 

I need to use a VPN with an IP from a specific US State. 

If the VPN IP address is banned, connect to another.

However openvpn over SSH won't help with that. It's only useful if your VPS is throttling or blocking VPNs. Otherwise you'll be wasting your VPS's resources on unnecessary double encryption.

Share this post


Link to post

Thats correct, the VPS IP address is being blocked by the program i am trying to use. 

 

I need to get the VPS to connect to VPN and when i SSH in, the connection is through the VPN so the program is not blocked. 

 

I hope im making sense. 

 

 

 

 

I'm not well versed in openvpn over SSH but if the command I gave you replies with the VPN's IP address, it must be working.

However why are you using this type of connection ? Is your VPS provider throttling VPNs ?

I am trying to run a program that my IP on the VPN is banned (not allowed to connect). 

I need to use a VPN with an IP from a specific US State. 

If the VPN IP address is banned, connect to another.

However openvpn over SSH won't help with that. It's only useful if your VPS is throttling or blocking VPNs. Otherwise you'll be wasting your VPS's resources on unnecessary double encryption.

Share this post


Link to post

I understand that you need a VPN because your VPS's IP address is being blocked, that's fine.

That doesn't justify the need to use openvpn over SSH even if you want to access your VPS with SSH. Those are two completely different things.

As I said earlier :

 

However openvpn over SSH won't help with that. It's only useful if your VPS provider is throttling or blocking VPNs. Otherwise you'll be wasting your VPS's resources on unnecessary double encryption.

 

Share this post


Link to post

Also I now get why you have the errors you mentioned earlier.

You added the commands I first gave you to the sh file that's used to connect to the VPN server which means this file is executed twice hence the port already in use !

Doing so won't cause any trouble (even though it's bad practice) so you can ignore the errors.

Share this post


Link to post

I understand that you need a VPN because your VPS's IP address is being blocked, that's fine.

That doesn't justify the need to use openvpn over SSH even if you want to access your VPS with SSH. Those are two completely different things.

With this being said then, as i am still fairly new to understanding command line vpn. 

How can i get the vps to connect via vpn and then log into that terminal to run my command lines. 

Share this post


Link to post

In the config generator page, retrieve the config file for UDP/443 and add the two lines to the ovpn file. (Use TCP/443 in the very unlikely case you have any problem connecting but that shouldn't happen since VPS networks are generally stable and neutral).

This time you'll need to create an sh file with the other two lines and then use chmod on it.

 

This way you'll still be able to access your VPS with SSH, save resources and get a faster VPN connection.

Share this post


Link to post

In the config generator page, retrieve the config file for UDP/443 and add the two lines to the ovpn file. (Use TCP/443 in the very unlikely case you have any problem connecting but that shouldn't happen since VPS networks are generally stable and neutral).

This time you'll need to create an sh file with the other two lines and then use chmod on it.

 

This way you'll still be able to access your VPS with SSH, save resources and get a faster VPN connection.

 

I done exactly what you said here. 

After running the .ovpn file i get this in the console:

 

debug1: Next authentication method: password

sshtunnel@108.177.134.74's password:

I don't know what the VPN password is !

Share this post


Link to post

Erase the files you previously downloaded from the config generator page!

All you should have is the new UDP/443 ovpn file and a new sh file containing only two lines

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Security Check
    Play CAPTCHA Audio
    Refresh Image

×
×
  • Create New...