Hi,
I'm new to Linux and Bash. I'm trying to automate VPN connection. I have started a .sh file to get rolling but I'm not sure how to pass my credentials from the executable into the Terminal. The script starts fine and the terminal window opens asking for my sudo password. I haven't been successful at figuring out how to pass the info from the file. Is it possible?
What I've got so far:
cd /etc/openvpn/ovpn_tcp
sudo openvpn us877.nordvpn.com.tcp.ovpn
Thanks in advance
Pass input from file to teminal
Forum rules
Before you post please read how to get help
Before you post please read how to get help
Re: Pass input from file to teminal
Rather than answering that let me ask: Are you aware that you can create a VPN connection via the NetworkManager? If you need OpenVPN specifically, there's a plugin for it available in the Software Manager.
Re: Pass input from file to teminal
You probably don't need to do that, but if you do, I searched with Startpage for 'bash read from file' and got a lot of good returns. Some of them even I could understand!

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
-
- Level 4
- Posts: 428
- Joined: Fri Sep 23, 2016 10:19 am
Re: Pass input from file to teminal
I don't recommend storing your password in a file, but if that's what you really want to do:
sudo requires -S to read password from stdin.
Code: Select all
cat .passwordfile | sudo -S openvpn us877.nordvpn.com.tcp.ovpn
If you abide in My word, you are My disciples indeed. And you shall know the truth, and the truth shall make you free... Most assuredly, I say to you, whoever commits sin is a slave of sin... Therefore if the Son makes you free, you shall be free indeed.