Skip to content

StepSisStuck/OpenVPN-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

OpenVPN-CLI

This project provides a comprehensive guide on how to set up a VPN server on a VPS using OpenVPN. Follow the instructions below to deploy and configure your VPN server.

Introduction to OpenVPN

OpenVPN is a robust and highly flexible open-source VPN (Virtual Private Network) software that enables secure point-to-point or site-to-site connections. It provides a secure and encrypted connection over the internet, ensuring privacy and data integrity. OpenVPN is widely used for remote access, secure communications, and bypassing geo-restrictions.

Benefits of OpenVPN

  • Security: OpenVPN uses strong encryption protocols to protect your data from unauthorized access.
  • Flexibility: It can be configured to work on various platforms and devices.
  • Reliability: OpenVPN is known for its stability and performance.
  • Open Source: Being open-source, it is continuously improved and audited by the community.

Prerequisites

Before you begin, ensure you have the following:

  • A VPS (Virtual Private Server) with a fresh installation of a supported Linux distribution (e.g., Ubuntu, Debian).
  • An Azure account to deploy the VM.
  • Putty installed on your local machine for SSH access.
  • Basic knowledge of Linux command-line operations.

Table of Contents

Deploy the VM on Azure

Azure VM Deployment

  • Make sure this is in username rather than SSH public key

How to connect using Putty

Step 1: Connect to the VM

Connect to VM

  • After creating the VM, click on connect

Step 2: Click on SSH

Click on SSH

  • Copy the SSH command only behind

Step 3: Open Putty and paste the SSH command

Paste SSH command

Step 4: Click on Yes

Step 5: Login

Login

Step 6: You are in the VM now

In the VM

Basic Start Command (Must do!!!)

sudo apt-get update && apt-get upgrade

Example output:

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
...
sudo apt install neovim

Example output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libmsgpackc2 libtermkey1 libvterm0 neovim-runtime
...

Create a non-root user

sudo useradd -G sudo -m  <username> -s /bin/bash

Example output:

Change the password

sudo passwd <username>

Example output:

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Installing the server

sudo apt install wget

Example output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpsl5 publicsuffix wget
...
wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh

Example output:

--2023-07-02 03:48:23--  https://git.io/vpn
Resolving git.io (git.io)... 140.82.113.21
Connecting to git.io (git.io)|140.82.113.21|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh [following]
--2023-07-02 03:48:23--  https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15345 (15K) [text/plain]
Saving to: ‘openvpn-install.sh’

openvpn-install.sh  100%[===================>]  15.00K  --.-KB/s    in 0.001s  

2023-07-02 03:48:23 (11.4 MB/s) - ‘openvpn-install.sh’ saved [15345/15345]
sudo bash openvpn-install.sh

Example output:

Welcome to the OpenVPN installer!
The git repository is available at: https://github.com/angristan/openvpn-install
I need to ask you a few questions before starting the setup.
You can use the default options and just press enter if you are unsure.
...

Follow the steps, it's on default settings if you press enter

Changing the directory for the ovpn file

sudo mv /root/<VPN file name example Aftershock.ovpn> .

Example output:

Disable Logs

sudo nvim /etc/openvpn/server/server.conf

Example output:

Change Verb 3 to Verb 0

After entering insert mode by pressing the "i" key in Nvim, you can type or modify the text as needed. To save the changes and exit the editor, you can follow these steps:

  1. Press the "Esc" key on your keyboard to exit insert mode and return to normal mode in Nvim.
  2. Once you're in normal mode, you can save the changes by typing :w (colon followed by the letter "w"). This command tells Nvim to write (save) the file.
  3. After entering :w, press the "Enter" key to execute the command. You should see a message indicating that the file has been saved.
  4. To exit Nvim, type :q (colon followed by the letter "q") and press "Enter". This command tells Nvim to quit the editor.
    • If you have unsaved changes and want to quit without saving, you can use :q! instead, which discards the changes and forces the exit.

By following these steps, you should be able to save your changes and exit the Nvim editor.

Restart the VPN Server

sudo systemctl restart openvpn-server@server.service

Example output:

How to download the files to your windows machine

Open CMD

pscp username@public_ip_address:/path/to/file C:\Downloads

Example output:

This is the example of the command

pscp CLF@52.123.45.67:thinkpad.ovpn C:\chanl\Downloads

Example output:

If you are lost follow this

YT video

Repository

Troubleshooting

Common Issues and Solutions

Issue: Unable to connect to the VM using SSH

  • Solution: Ensure that the VM is running and the SSH port (usually port 22) is open in the VM's network security group settings.

Issue: Permission denied when running commands

  • Solution: Make sure you are using a user with sudo privileges. If you are using a non-root user, prefix the commands with sudo.

Issue: OpenVPN service not starting

  • Solution: Check the OpenVPN server logs for any error messages. You can view the logs using the following command:
    sudo journalctl -u openvpn-server@server.service

Issue: Unable to download files using pscp

  • Solution: Ensure that the pscp command is installed on your Windows machine. You can download it from the official PuTTY website. Also, verify that the file path and IP address are correct.

For further assistance, refer to the official OpenVPN documentation or seek help from the OpenVPN community.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published