Auto Connect Vpn Script on Linux at Boot

Auto Connect Vpn Script on Linux at Boot

I'm writing a bash script on linux to run at each boot. This script serves to connect automatically on a surfshark vpn server at boot.

This is my script:

#! /bin/bash 
echo "1"|sudo surfshark-vpn attack

I use this code to add administrator property to my script:

sudo chmod +x scriptVPN.sh

I use different guide to run this script on boot but none of these work. Can you help me?

2 Answers

As an alternative you can create a systemd unit file which will accomplish the task at boot.

Update your shell script to:

#! /bin/bash echo -e "\n" | sudo surfshark-vpn attack

echo -e (with -e) allows the command echo to interpret backslash escapes i.e. it will press 'enter' after sudo surfshark-vpn attack

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.