Ask Your Question

pass credentials using a bash script

asked 2018-02-18 01:24:45 +0000

horndog gravatar image

updated 2018-02-18 12:13:40 +0000

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 12:18:55 +0000

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: https://stackoverflow.com/a/11955358/... , 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 ( 2018-02-23 22:06:24 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

1 follower


Asked: 2018-02-18 01:24:45 +0000

Seen: 58 times

Last updated: Feb 23