Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Default Variable Declarations
  4. DEFAULT="Default.txt"
  5. FILEEXT=".ovpn"
  6. CRT=".crt"
  7. KEY=".3des.key"
  8. CA="ca.crt"
  9. TA="ta.key"
  10.  
  11. #Ask for a Client name
  12. echo "Please enter an existing Client Name:"
  13. read NAME
  14.  
  15.  
  16. #1st Verify that client’s Public Key Exists
  17. if [ ! -f $NAME$CRT ]; then
  18. echo "[ERROR]: Client Public Key Certificate not found: $NAME$CRT"
  19. exit
  20. fi
  21. echo "Client’s cert found: $NAME$CR"
  22.  
  23.  
  24. #Then, verify that there is a private key for that client
  25. if [ ! -f $NAME$KEY ]; then
  26. echo "[ERROR]: Client 3des Private Key not found: $NAME$KEY"
  27. exit
  28. fi
  29. echo "Client’s Private Key found: $NAME$KEY"
  30.  
  31. #Confirm the CA public key exists
  32. if [ ! -f $CA ]; then
  33. echo "[ERROR]: CA Public Key not found: $CA"
  34. exit
  35. fi
  36. echo "CA public Key found: $CA"
  37.  
  38. #Confirm the tls-auth ta key file exists
  39. if [ ! -f $TA ]; then
  40. echo "[ERROR]: tls-auth Key not found: $TA"
  41. exit
  42. fi
  43. echo "tls-auth Private Key found: $TA"
  44.  
  45. #Ready to make a new .opvn file - Start by populating with the
  46. #default file
  47. cat $DEFAULT > $NAME$FILEEXT
  48.  
  49. #Now, append the CA Public Cert
  50. echo "<ca>" >> $NAME$FILEEXT
  51. cat $CA >> $NAME$FILEEXT
  52. echo "</ca>" >> $NAME$FILEEXT
  53.  
  54. #Next append the client Public Cert
  55. echo "<cert>" >> $NAME$FILEEXT
  56. cat $NAME$CRT | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $NAME$FILEEXT
  57. echo "</cert>" >> $NAME$FILEEXT
  58.  
  59. #Then, append the client Private Key
  60. echo "<key>" >> $NAME$FILEEXT
  61. cat $NAME$KEY >> $NAME$FILEEXT
  62. echo "</key>" >> $NAME$FILEEXT
  63.  
  64. #Finally, append the TA Private Key
  65. echo "<tls-auth>" >> $NAME$FILEEXT
  66. cat $TA >> $NAME$FILEEXT
  67. echo "</tls-auth>" >> $NAME$FILEEXT
  68.  
  69. echo "Done! $NAME$FILEEXT Successfully Created."
  70.  
  71. #Script written by Eric Jodoin
  72. # \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement