Saving credentials and secrets inside your code is a very bad idea and should be avoided. PowerShell has built-in commands to export and import encrypted data in your code.
There might be a lot of ways to achieve this, but this is how I like to do it. This is very elegant and easy to implement.
Let’s say we have a secret password that we want to secure and avoid saving in the source code.
While it’s good to know how things work, the task gets boring and repetitive if you have to do it every 3 months and in my case for two different domains. This is why I wrote a small and straightforward script in Python3 that does that all for me.
ZeroSSL offers an API that allows us to automate this task by making some HTTP calls with an API key obtainable after registering.
I have uploaded the script on GitHub, check it out:
What is DNS over HTTPS ? Well it’s basically an encrypted way of querying DNS. Normally DNS uses port 53 to communicate with the server and query the name we want. But all of that traffic is in plain-text and thus it is very easy to poison that communication. DNS over HTTPS is secure because it uses certificates to encrypt traffic (just like HTTPS websites).
Mozilla Firefox makes it very easy to enable this feature. Just open the settings and search for “DNS over HTTPS”:
It was very cheap (4$ or 3.75€ annually), but with a lot of gotchas.
One of them is Ubuntu 18.04 Minimal, which means a lot of packages will not be pre-installed, causing a lot of pain when installing services like in my example OpenVPN.
Here is how I managed to install OpenVPN on Ubuntu 18.04 Minimal.
The first problem occurs with the root CA certificates:
Install the root certificates in order to trust them:
apt-get install ca-certificates
After re-running the command, another error shows up:
Install the next package (iptables):
apt-get install iptables
And finally, the OpenVPN setup can be run:
I had to set a custom port, because only specific ones were NAT’d to my server. You might leave the port to default. I am also using 1.1.1.1 for DNS.
After the setup is finished, a configuration file will be created. This file contains the public certificates and private key that are mandatory for the connection. It can be imported into the OpenVPN client (Windows) through the GUI.
On Linux, a simple
openvpn configfile.ovpn
does the trick.
If you are looking for a VPS with good performance, check out Evolution Host at https://evolution-host.com/vps-hosting.php. They offer virtual servers starting at 5€ per month.