Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. echo -e "\n*****\n* Generating Diffie-Hellman parameters for better security.\n*****\n"
  4.  
  5. # Add Diffie-Hellman parameters.
  6. # Create secure Diffie-Hellman parameters.
  7. sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
  8.  
  9. NGINX_CONF="/etc/nginx/sites-available/default"
  10.  
  11. # Get last occurrence of parentheses that closes the code block.
  12. LAST_OCCURANCE=$(grep --line-number } "$NGINX_CONF" | cut --delimiter=: --fields=1 | tail --lines=2 | head --lines=1)
  13.  
  14. # Add new parameters to server block
  15. SECURE_DH_PEM="ssl_dhparam /etc/ssl/certs/dhparam.pem;"
  16. sudo sed --in-place "$LAST_OCCURANCE s%\(}\)%\1\n $SECURE_DH_PEM%" "$NGINX_CONF"
  17.  
  18. # Restart Nginx
  19. sudo systemctl reload nginx
  20.  
  21.  
  22. # Ask for valid email.
  23. # -e - Input coming from terminal.
  24. # -p - Prompt for input.
  25. read -ep "Enter valid email for account retrieval: " EMAIL
  26.  
  27. HOST_NAME=$(hostname)
  28.  
  29. # Install Certbot Let's Encrypt client for certificates on Nginx.
  30. sudo add-apt-repository -y ppa:certbot/certbot
  31. sudo apt-get update
  32. sudo apt-get -y install python-certbot-nginx
  33.  
  34. # Auto configure: Authenticate and install certificate.
  35. sudo certbot --nginx \
  36. --domain ${HOST_NAME}.eastus.cloudapp.azure.com \
  37. --email ${EMAIL} \
  38. --agree-tos \
  39. --no-eff-email \
  40. --non-interactive \
  41. --redirect \
  42. --test-cert
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement