Bobcares

Setting up SSH key on OpenVPN Server

by | Sep 18, 2019

Looking for an easy and secure way to login to your server?

Setting up SSH key on OpenVPN Server helps to connect to the server efficiently. However, errors are common while setting up this SSH connection.

At Bobcares, we receive many requests to solve OpenVPN connection errors as part of our VPN Management Services.

Today, let’s see how our Support Engineers set up the connection and fix the related errors.

 

How to setup ssh key for OpenVPN?

As a matter of fact, VPN helps to have a secure connection to another network over the Internet.

OpenVPN is one popular open-source software that implements VPN. It uses SSL/TLS based protocol to establish a secure connection between the VPN client and server. Again for users who like to have quicker access to external servers, the ssh key method will be one of the best options. Moreover, it eliminates the need to remember the server password each time.

However, connecting to the server using OpenVPN requires a series of steps. Let’s now take a look at how our Dedicated Engineers implement it.

1. Firstly, we install OpenVPN on the server.

2. To run OpenVPN, we must have a user account on our server. So, we add a user using the command,

 sudo useradd newuser

3. After that, we create the home directory for the user and the user directory needed for SSH. We also change the permissions and provide privileges to the user. Depending on the auth mechanism running on the server, we modify the server settings. For instance, if the server uses the sudo method, we add the newuser in the sudoers file. Again, in some other servers, we just add the user to the wheel group.

For users having difficulty in managing users via command-line, we recommend the use of a web panel. Here, we can also add and check the user permissions in the OpenVPN server interface.

 

 

4. Next, we generate the SSH public key and private key in the client machine using the ssh-keygen command. The default location of the ssh public key is ~/.ssh/id_rsa.pub in the server.

5. We copy the public key to a file and move the file to the VPN server and execute the commands,

sudo cp newuser.pub ~newuser/.ssh/authorized_keys
sudo chown newuser:newuser ~newuser/.ssh/authorized_keys
sudo chmod 600 ~newuser/.ssh/authorized_keys

Now newuser will be able to login to the OpenVPN machine using the ssh private key.

 

Common errors in OpenVPN ssh key-based method

Usually, users face many errors while connecting OpenVPN using ssh keys. Let’s have a look at some common errors and respective fixes.

 

1. Error in the configuration file

Recently, one of our customers approached us with an OpenVPN connection failed error.

Our Support Engineers checked the issue and found out errors in the VPN configuration file. The server address was set to some wrong hostname.

Therefore, correcting the server address in the OpenVPN client config resolved the error.

 

2. Change in port numbers

Firewall restrictions can also cause VPN connectivity errors.

By default, OpenVPN uses UDP/TCP port number 1194. Some servers may have port forwarding rules that allow the VPN connection. Such changes in port number could also lead to an OpenVPN connection failed error.

Therefore, it is important to check the port number during OpenVPN connections based on SSH.

 

3. Incorrect SSL/TLS key settings

Sometimes, the SSL key used for SSL encryption/decryption can be different on the client and the server-side. This causes TLS out of sync errors during connection establishment.

Therefore, when the client and server are communicating with each other, we always ensure that they are agreeing upon the same TLS keys.

 

[Need more assistance in connecting OpenVPN using ssh keys?- We’ll help you.]

 

Conclusion

In short, the errors while connecting OpenVPN using ssh key mainly occur due to mistakes in the configuration file, port settings and so on. Today’s write-up discussed how our Support Engineers set up the OpenVPN ssh key connection and fix the errors related to it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

1 Comment

  1. harshan

    good piece of information…..

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.