title: Bash script to automate Open VPN
body: <p>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.</p>
  
  <pre><code>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 &lt;&lt;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 .
  </code></pre>
  
  <p>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?</p>
  
  <p>EDIT: I solved it</p>