mirror of
https://github.com/pivpn/pivpn.git
synced 2025-01-19 19:09:46 +00:00
'pivpn add' functionality greatly improved!
Now with 2 scoops of raisins!
This commit is contained in:
parent
582e923bc8
commit
af19eeb55b
2 changed files with 54 additions and 11 deletions
2
pivpn
2
pivpn
|
@ -36,7 +36,7 @@ function uninstallFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
function versionFunc {
|
function versionFunc {
|
||||||
printf "\e[1mVersion 1.1\e[0m\n"
|
printf "\e[1mVersion 1.2\e[0m\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function helpFunc {
|
function helpFunc {
|
||||||
|
|
|
@ -10,15 +10,55 @@ CA="ca.crt"
|
||||||
TA="ta.key"
|
TA="ta.key"
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||||
|
|
||||||
echo "Please enter a Name for the Client:"
|
printf "Enter a Name for the Client: "
|
||||||
read NAME
|
read NAME
|
||||||
|
|
||||||
|
stty -echo
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
printf "Enter the password for the Client: "
|
||||||
|
read PASSWD
|
||||||
|
printf "\n"
|
||||||
|
printf "Enter the password again to verify: "
|
||||||
|
read PASSWD2
|
||||||
|
printf "\n"
|
||||||
|
[ "$PASSWD" = "$PASSWD2" ] && break
|
||||||
|
printf "Passwords do not match! Please try again.\n"
|
||||||
|
done
|
||||||
|
stty echo
|
||||||
|
|
||||||
#Build the client key and then encrypt the key
|
#Build the client key and then encrypt the key
|
||||||
cd /etc/openvpn/easy-rsa
|
cd /etc/openvpn/easy-rsa
|
||||||
source /etc/openvpn/easy-rsa/vars
|
source /etc/openvpn/easy-rsa/vars
|
||||||
./build-key-pass $NAME
|
|
||||||
|
expect << EOF
|
||||||
|
spawn ./build-key-pass $NAME
|
||||||
|
expect "Enter PEM pass phrase" { send "$PASSWD\r" }
|
||||||
|
expect "Verifying - Enter PEM pass phrase" { send "$PASSWD\r" }
|
||||||
|
expect "Country Name" { send "\r" }
|
||||||
|
expect "State or Province Name" { send "\r" }
|
||||||
|
expect "Locality Name" { send "\r" }
|
||||||
|
expect "Organization Name" { send "\r" }
|
||||||
|
expect "Organizational Unit" { send "\r" }
|
||||||
|
expect "Common Name" { send "\r" }
|
||||||
|
expect "Name" { send "\r" }
|
||||||
|
expect "Email Address" { send "\r" }
|
||||||
|
expect "challenge password" { send "\r" }
|
||||||
|
expect "optional company name" { send "\r" }
|
||||||
|
expect "Sign the certificate" { send "y\r" }
|
||||||
|
expect "commit" { send "y\r" }
|
||||||
|
expect eof
|
||||||
|
EOF
|
||||||
|
|
||||||
cd keys
|
cd keys
|
||||||
openssl rsa -in $NAME$OKEY -des3 -out $NAME$KEY
|
|
||||||
|
expect << EOF
|
||||||
|
spawn openssl rsa -in $NAME$OKEY -des3 -out $NAME$KEY
|
||||||
|
expect "Enter pass phrase for" { send "$PASSWD\r" }
|
||||||
|
expect "Enter PEM pass phrase" { send "$PASSWD\r" }
|
||||||
|
expect "Verifying - Enter PEM pass" { send "$PASSWD\r" }
|
||||||
|
expect eof
|
||||||
|
EOF
|
||||||
|
|
||||||
#1st Verify that clients Public Key Exists
|
#1st Verify that clients Public Key Exists
|
||||||
if [ ! -f $NAME$CRT ]; then
|
if [ ! -f $NAME$CRT ]; then
|
||||||
|
@ -74,8 +114,11 @@ echo "</tls-auth>" >> $NAME$FILEEXT
|
||||||
|
|
||||||
# Copy the .ovpn profile to the home directory for convenient remote access
|
# Copy the .ovpn profile to the home directory for convenient remote access
|
||||||
cp /etc/openvpn/easy-rsa/keys/$NAME$FILEEXT /home/$INSTALL_USER/ovpns/$NAME$FILEEXT
|
cp /etc/openvpn/easy-rsa/keys/$NAME$FILEEXT /home/$INSTALL_USER/ovpns/$NAME$FILEEXT
|
||||||
echo "$NAME$FILEEXT moved to home directory."
|
chown $INSTALL_USER /home/$INSTALL_USER/ovpns/$NAME$FILEEXT
|
||||||
whiptail --title "MakeOVPN" --msgbox "Done! $NAME$FILEEXT successfully created and \
|
printf "\n\n"
|
||||||
moved to directory /home/$INSTALL_USER/ovpns." 8 78
|
printf "========================================================\n"
|
||||||
|
printf "\e[1mDone! $NAME$FILEEXT successfully created!\e[0m \n"
|
||||||
# Original script written by Eric Jodoin.
|
printf "$NAME$FILEEXT was copied to:\n"
|
||||||
|
printf " /home/$INSTALL_USER/ovpns\n"
|
||||||
|
printf "for easy transfer.\n"
|
||||||
|
printf "========================================================\n\n"
|
||||||
|
|
Loading…
Add table
Reference in a new issue