so what I'm trying to do is to write a Bash script that will ssh into a server and generate new user credentials. However, it won't create the new user keys, but it can tell you if a user already exists.
echo "You entered $NAME. Is this correct?(y/n) "
read AN
while [ "$AN" != "y" ]
do
echo "Enter the correct user name: "
read NAME
echo "You entered $NAME. Is this correct(y/n)? "
read AN
done
ssh -t x@0.0.0.0 <<EOF
if [ ! -e /etc/openvpn/easy-rsa/keys/"$NAME.crt" ]
then
cd /etc/openvpn/easy-rsa/
source vars
./pkitool "$NAME"
else
echo "File already exists!"
fi
exit
EOF
scp x@0.0.0.0:/etc/openvpn/easy-rsa/keys/$NAME.crt .
This code can generate new user keys, but when I add the if block, it then will no longer create new keys for some reason. Anybody have any ideas why the if block doesn't properly work?
EDIT: I solved it