VPN Systemd

1 minute read Published:

VPN with systemd.

When using services like Hack The Box or Try Hack Me you usually have to connect using a VPN. This can be a pain to manage, and so I have written an ansible role to create systemd services to manage this.

The role file can be found here

  1. The role file takes the arguments htbpath, this is the path for where the Hack The Box cert needs to be, and thmpath which is the same but for Try Hack Me. These can be modified to fit whatever site you use. I suggest setting both to ~/.certs/ or similar.

  2. You will also need to store the ovpn files in the template directory. Then the role will create the folder, copy the ovpn files and create a systemd service.

The systemd template can be found here.

Its really just a standard .service file.

Result

example playbook:

---
- hosts: kali
  vars:
	htbpath: ~/.certs/
	thmpath: ~/.certs/
  roles:
    - htbthmcerts

Directory Structure

/etc/ansible/roles/htbthmcerts
├── tasks
│   └── main.yaml
└── templates
    ├── HTB.ovpn
    ├── HTB.service.j2
    ├── THM.ovpn
    └── THP.service.j2