You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6 KiB

  1. #!/bin/bash
  2. #
  3. BORDER=">>>>>>>>>>>>>>>>"
  4. printf "$BORDER Setting up base client config file\n\n"
  5. mkdir -p ~/client-configs/files
  6. chmod 700 ~/client-configs/files
  7. cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/client-configs/base.conf
  8. sed -i "s/my-server-1 1194/192.168.2.2 443/g" ~/client-configs/base.conf
  9. sed -i "s/proto udp/proto tcp/g" ~/client-configs/base.conf
  10. sed -i "s/;user nobody/user nobody/g" ~/client-configs/base.conf
  11. sed -i "s/;group nobody/group nobody/g" ~/client-configs/base.conf
  12. sed -i "s/ca ca.crt/# ca ca.crt/g" ~/client-configs/base.conf
  13. sed -i "s/cert client.crt/# cert client.crt/g" ~/client-configs/base.conf
  14. sed -i "s/key client.key/# key client.key/g" ~/client-configs/base.conf
  15. cat >> ~/client-configs/base.conf << EOF
  16. cipher AES-128-CBC
  17. auth SHA256
  18. key-direction 1
  19. # script-security 2
  20. # up /etc/openvpn/update-resolv-conf
  21. # down /etc/openvpn/update-resolv-conf
  22. EOF
  23. printf "$BORDER Creating make client config script..\n\n"
  24. touch ~/client-configs/make_config.sh
  25. cat >> ~/client-configs/make_config.sh << EOF
  26. #!/bin/bash
  27. # First argument: Client identifier
  28. KEY_DIR=~/openvpn-ca/keys
  29. OUTPUT_DIR=~/client-configs/files
  30. BASE_CONFIG=~/client-configs/base.conf
  31. cat \${BASE_CONFIG} <(echo -e '<ca>') \${KEY_DIR}/ca.crt <(echo -e '</ca>\n<cert>') \${KEY_DIR}/\${1}.crt <(echo -e '</cert>\n<key>') \${KEY_DIR}/\${1}.key <(echo -e '</key>\n<tls-auth>') \${KEY_DIR}/ta.key <(echo -e '</tls-auth>') > \${OUTPUT_DIR}/\${1}.ovpn
  32. EOF
  33. chmod 700 ~/client-configs/make_config.sh
  34. printf "$BORDER Making client config file for client1\n\n"
  35. cd ~/client-configs
  36. ./make_config.sh client1
  37. ls ~/client-configs/files