Created
February 16, 2020 13:33
-
-
Save prasathmani/4869b135fbf02c175ae7b5a0f132125e to your computer and use it in GitHub Desktop.
LetsEncrypt SSL cert on GoDaddy Shared Hosting using acme.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre required SSH access | |
## Download and install acme.sh | |
acme.sh is a full implementation of a LetsEncrypt client but that doesn't depend on Python/pip/virtualenv/etc, and that doesn't require root -- exactly what we need, since we don't have root an a shared GoDaddy server, and we can't install new software outside of our home directory. | |
`curl https://get.acme.sh | sh` | |
Now log out and SSH back in so acme.sh's install is complete in every way (include the Bash alias). | |
##Get GoDaddy API Key | |
Visit `https://developer.godaddy.com/keys/` | |
Generate a production key (it made me produce a test key first for some reason...) | |
In the SSH session you have open run these commands, but with each ... replaced by the value GoDaddy gave you in the previous step: | |
```export GD_Secret=... | |
export GD_Key=.``` | |
Run, | |
`acme.sh --issue -d MYDOMAIN.com -d www.MYDOMAIN.com -w ~/www --dns dns_gd` | |
(Yes, literally `~/www`, no trailing `/.`) | |
(NOTE: If you're creating this cert for a domain that's not the default domain being hosted on this server, then instead of `~/www` you'll need to do something like `~/www/MYOTHERDOMAIN.COM.`) | |
Boom! You should have just gotten your first good news of the day -- your cert, cert key, intermediate CA cert, and full cert chain have been generated! | |
...but GoDaddy still doesn't know that the cert exists, so it's not using it. | |
#Upload cert and private key to GoDaddy via acme.sh --deploy | |
Turns out that CPanel, the web interface you use to manage your server (which you saw earlier when you gave yourself SSH access), has an API, and we can call it from our GoDaddy server! | |
Use nano to open `~/.acme.sh/deploy/cpanel_uapi.sh`, uncomment the `DEPLOY_CPANEL_USER` variable at the top, set its value to your user ID (without the t at the beginning) | |
Run `acme.sh --deploy -d MYDOMAIN.com --deploy-hook cpanel_uapi` | |
After ~30 seconds, you should see output like this! | |
` | |
[Sun Sep 17 03:17:45 MST 2020] Certificate successfully deployed | |
[Sun Sep 17 03:17:45 MST 2020] Success` | |
#Redirect my cPanel website to HTTPS | |
Click on public_html, and open your `.htaccess` if you already have one. If not, click File+, name the file `.htaccess` and click Create New File | |
add folowing code | |
``` | |
RewriteEngine On | |
RewriteCond %{SERVER_PORT} 80 | |
RewriteCond %{HTTP_HOST} ^(www\.)?coolexample\.com | |
RewriteRule ^(.*)$ https://www.coolexample.com/$1 [R,L]``` | |
##Reference sites | |
https://tryingtobeawesome.com/encryptdaddy/ | |
https://in.godaddy.com/help/redirect-my-cpanel-website-to-https-27870 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment