How to obtain free SSL (HTTPs) certificate for your domain using few lines in terminal

Oleg Khomenko
1 min readFeb 4, 2022
SSL Certificate is required to use your IP or Domain Name and communicate via https protocol

tl;dr:

# Add firewall rule (optional)
sudo ufw allow 80
# Get certificate for %DOMAIN_NAME%
sudo certbot certonly --standalone --preferred-challenges http -d %DOMAIN_NAME%
# Delete firewall rule (optional)
sudo ufw delete allow 80
# Check obtained certificates
>> sudo ls /etc/letsencrypt/live/{your-domain-name}
README cert.pem chain.pem fullchain.pem privkey.pem

HowTo:

We will use certbot for that

# Install certbot app
sudo apt-get install certbot
# Use it
sudo apt install certbot python3-certbot-nginx

Then

sudo certbot run -n --nginx --agree-tos -d blue.iq.mynalabs.ai,www.blue.iq.mynalabs.ai -m  mygmailid@gmail.com  --redirect

Don’t forget to turn off nginx:

systemctl stop nginx

All certificates are (by default) in:

>> sudo ls /etc/letsencrypt/live/{your-domain-name}
README cert.pem chain.pem fullchain.pem privkey.pem

To check the certificate to be valid:

sudo cat /etc/letsencrypt/live/{your-domain-name}/cert.pem | openssl x509 -noout -enddate -startdate

That’s it. You are awesome

--

--