Ask Your Question

pass credentials using a bash script

asked 2018-02-17 19:24:45 -0500

horndog gravatar image

updated 2018-02-18 06:13:40 -0500

FranciscoD_ gravatar image

I'm using Fedora 27 and trying to learn scripting, so I thought I'd try a "simple' login scrip for openvpn.

I need to pass the sudo password, Auth Username, and Auth Password. These credentials would be in the script itself. Security principles are not important since this is a learning exercise. The simple format would look like:

sudo openvpn xx.ovpn
[sudo] password for user:
Enter Auth Username:
Enter Auth Password:

I've found several scripts online, but none work. Am I trying to do something that can't be done? Thanks for any help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-18 06:18:55 -0500

FranciscoD_ gravatar image

Hi! This isn't a Fedora specific question, and I'm certain general Linux forums such as stackexchange would have this discussed at length already.

Here is how one can give sudo a password using STDIN: , for example.

For openvpn, the man page tells me that there are different ways of providing credentials, such as using --auth-user-pass <file with username and password>.

So, it can be done, even if it is not suggested. The lesson to take from here, perhaps, is to spend more reading documentation, since both answers were in man sudo and man openvpn :)

edit flag offensive delete link more



Thank you.

horndog gravatar imagehorndog ( 2018-02-23 16:06:24 -0500 )edit

Question Tools

1 follower


Asked: 2018-02-17 19:24:45 -0500

Seen: 318 times

Last updated: Feb 23 '18