> For the complete documentation index, see [llms.txt](https://asafahmadov.gitbook.io/hands-on-projects/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asafahmadov.gitbook.io/hands-on-projects/extra-security/vpn-connection/openvpn-server-on-google-cloud-platform.md).

# OpenVPN Server on Google Cloud Platform

### **STEP 1: Navigate to Google Marketplace** <a href="#id-96cc" id="id-96cc"></a>

* Top left click on three horizontal lines
* Search for Marketplace (aka Cloud Launcher)<br>

  <figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FEYvk75cQbCWm7CtygrUq%2Fimage.png?alt=media&amp;token=88bfe686-3926-44f6-8f1c-c88030a4a375" alt=""><figcaption></figcaption></figure>

### **STEP 2: Search for OpenVPN** <a href="#abef" id="abef"></a>

* In search box type “openvpn” and hit enter
* In my case it is first result click on it to navigate to OpenVPN server page
*

```
<figure><img src="/files/dano6yOYFo8ykMfkkm9q" alt=""><figcaption></figcaption></figure>
```

### **STEP 3: OpenVPN Access Server Overview** <a href="#d572" id="d572"></a>

* With OpenVPN Access Server free option you will get two concurrent VPN connections for free.
* You can obtain a software license if more than two concurrent connections are needed.
* You can customise the configuration later when deploying this solution.
* Ensure to check the monthly estimate total.

### **STEP 4: Enable Google APIS** <a href="#f949" id="f949"></a>

Enable below Google APIs before deploying Virtual Instance with OpenVPN Access Server

Enable these APIs navigating to “APIs and Service page” or directly as instructed in below image

* Compute Engine API : compute.googleapis.com

> Creates and runs virtual machines on Google Cloud Platform.

* Cloud Deployment Manager V2 API: deploymentmanager.googleapis.com

> The Google Cloud Deployment Manager v2 API provides services for configuring, deploying, and viewing Google Cloud services and APIs via templates which specify deployments of Cloud resources.

* Cloud Runtime Configuration API: runtimeconfig.googleapis.com

> This Runtime Configurator allows you to dynamically configure and expose variables through Google Cloud Platform. In addition, you can also set Watchers and Waiters that will watch for changes to your data and return based on certain conditions.

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FyJhRxjIyCFfI6jfSQQAa%2Fimage.png?alt=media&amp;token=a6918da7-55ff-4886-84ac-a9cdc8bc4855" alt=""><figcaption></figcaption></figure>

You will see something similar image after clicking on **ENABLE** button as per the above image

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FDLX0ptBIY7hWmBGZDIdk%2Fimage.png?alt=media&amp;token=12ace509-1b73-463c-b34a-34939d38c2c0" alt=""><figcaption></figcaption></figure>

### **STEP 5: OpenVPN Server Deployment Configuration** <a href="#id-1721" id="id-1721"></a>

* Choose deployment name
* Select zone, machine type and set source ip to access this instance
* Check infrastructure fee before proceeding to deploy.

Once all set then click on **DEPLOY**<br>

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FJG8nwmxw9wPGOfe4HI0x%2Fimage.png?alt=media&amp;token=94afc60b-5fbf-479d-88ce-ff05c8feb1ec" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FZU436N8gOUK2oBRdrXxr%2Fimage.png?alt=media&amp;token=7ffa9e8a-9432-467f-bffc-1fa08ccf0dc4" alt=""><figcaption></figcaption></figure>

### STEP 6: Enable SSH Access to OpenVPN Access Server (Option) <a href="#fe87" id="fe87"></a>

use below GCloud Command or create new firewall from GCP Console

> gcloud compute — project=\<project-name> firewall-rules create vm-openvpn-access-server-tcp-22 — direction=INGRESS — priority=1000 — network=\<vpc-name> — action=ALLOW — rules=tcp:22 — source-ranges=0.0.0.0/0 — target-tags=\<vm-tag>

### **STEP 7: Access OpenVN Server Admin URL** <a href="#d001" id="d001"></a>

* Type https\://\<OpenVPN-Access-Server-IP>:943/admin/ in browser and you will see something similar
* Type your username and password and post successful login, you will be navigated to “Status Overview” page

  <figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2F8SMuQ6NjobjywYfQp7iD%2Fimage.png?alt=media&amp;token=9a7bbdbd-4a22-49a0-88ff-815d260984e7" alt=""><figcaption></figcaption></figure>

from Admin page you can do configurations as per your need.<br>

{% hint style="success" %}
Securing OpenVPN involves multiple layers of configuration and best practices. When it comes to user management, particularly if you're referring to the administrative aspect of OpenVPN, it's essential to secure access. Here are some best practices:<br>

1. **Change the Default Password:** If there's a default administrative password provided during the OpenVPN setup, change it immediately to prevent unauthorized access. Using a strong password is critical.
2. **Add Extra Users with Least Privilege:** If multiple individuals need access to the OpenVPN administration or its components, create separate user accounts for them. Always follow the principle of least privilege, meaning users should only have the permissions they need to do their job and nothing more. For instance, not everyone needs administrative rights.
3. **Use Multi-Factor Authentication (MFA):** If possible, implement multi-factor authentication for accessing the VPN. This provides an additional layer of security, ensuring that even if someone gets hold of a user's password, they still can't access the VPN without the second factor.
4. **Restrict Access by Source IP:** If you know the specific IP ranges or addresses that should have access to the administrative interface, restrict access to only those IPs.
5. **Use TLS Authentication:** This involves having a shared secret that needs to be present for a client to connect to the OpenVPN server, adding an extra layer of security on top of the regular username and password.
6. **Regularly Update OpenVPN:** Always keep your OpenVPN server and clients updated to ensure any security patches are applied.
   {% endhint %}

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2F987zOTO2P6R8OzEzQvC9%2Fimage.png?alt=media&amp;token=aece9d37-285e-4ba2-8a20-fc761823adc4" alt=""><figcaption></figcaption></figure>

### **STEP 8: Access to Non-Admin Page** <a href="#id-71d7" id="id-71d7"></a>

* [https://\<OpenVPN Access Server IP>:443/](https://34.67.192.92/)
* if no user user is created then you can use same Admin credential to login
* Download and Install OpenVPN Client Connection profile as per your machine OS (Go with latest only)<br>

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2F1rPfVMvYBSSsCZtGuklg%2Fopenvpn.png?alt=media&amp;token=ae768994-4d8e-4fb7-9096-4b91a9da40b0" alt=""><figcaption></figcaption></figure>

### **STEP 9: Click on OpenVPN Connect Icon** <a href="#b973" id="b973"></a>

* I have installed on my WindowsOS
* Click on OpenVPN Client to connect to OpenVPN Server

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2Fg1FVnpC9h2PivQXj4Gdo%2Fimage.png?alt=media&amp;token=118d3e46-125e-45c6-84ca-680a38b7648a" alt=""><figcaption></figcaption></figure>

### STEP 10: Connect to OpenVPN Server <a href="#id-1ed6" id="id-1ed6"></a>

* Enter your user/admin credential to connect
* Post login status will set to CONNECTED if all good

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FIod7S3DwhPaNAA4bW00s%2Fimage.png?alt=media&amp;token=1a7d426f-b436-416c-b1c6-47607aff3897" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2Fs6mA0RLs6Huvfc8sYMhi%2Fimage.png?alt=media&amp;token=cf1a0f0d-e7e8-4ed5-8216-e81f8d8861e0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2Frpns0YUzowwbZPpiJONC%2Fimage.png?alt=media&amp;token=57f15127-8b18-49e7-a8f3-e585c1c3221d" alt=""><figcaption></figcaption></figure>

### STEP 11: Validate Private IP <a href="#id-00f1" id="id-00f1"></a>

* Check private ip assigned to your machine.

<figure><img src="https://3780827056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZJs5tQDEhqdUzV8OKFwp%2Fuploads%2FtxzTsyzHHhHfjhsfNhbJ%2Fimage.png?alt=media&amp;token=79ac3c7d-6c69-449b-8835-25962b03e714" alt=""><figcaption></figcaption></figure>
