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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF