Categories
identity

Create OpenVPN credentials File

In order to take a password from the shell and append to a file (e.g. OpenVPN).

#!/bin/bash

fname=/etc/openvpn/authcreds
[[ ! -r ${fname} ]] || rm ${fname}

read -s -p "Enter usn:" usn
echo "${usn}" >> "${fname}"
echo ""

read -s -p "Enter pwd:" pwd
cat <<< "$pwd" >> "${fname}"

chown root:root ${fname}
chmod 0644 ${fname}

printf "\nCredential file is ${fname}.\n"

So the default credentials file is named ‘authcreds’ unless the first argument provided is the desired filename.

The user is prompted for their username and password which are added to the file. Username on first line, password on the second.

Leave a Reply