Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
VPNs are all the rage. All the cool kids are using them. The coolest kids only use a terminal on their linux. How about running openvpn as a systemd service and have an interactive prompt to let you know that your vpn isĀ running?
Enter systemd, and PS1.The trick is to run the openvpn command as a systemd service. Then set it to auto-restart 15 seconds after failure. If we add a line to the opvn config file, auth-user-pass /home/linuxuser/pass.txt and then have the openvpn username and password in said txt file openvpn will be able to automatically connect to the vpn host. Finally, the icing on the cake is to update my PS1 (terminal prompt) to change color if the vpn is connected. This can be accomplished two different ways. 1). If the traceroute resolves the first hop to a 10.* ip address then I know that my vpn is connected2). If the service is in an active state then I know itsĀ running.
The in depth process isĀ below.
There you have it, the vpn service will start on boot and will remain running all the time. If there is an issue then it will autorestart after 15 seconds. Just as a safeguard to make sure that all is good because we always want to know if the vpn is runningĀ ;) our terminal prompt will change colors based on the situation. A further enhancement can be done if you donāt want the entire terminal to change color and just hav ea symbol. This can be done if you look at the git integration that was done by, magicmonty. Hope this was a quick and easy read, and good luck with all yourĀ VPN-ing!
links!!
- systemd.service
- BASH Shell Change The Color of Shell Prompt on Linux or UNIX - nixCraft
- My new favorite Bash prompt - BrettTerpstra.com
Running openvpn as a systemd service. was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.