April 22, 2025

Introduction

Securing your website with HTTPS is crucial to protect your users’ data and enhance trust. In this blog post, we’ll walk you through the process of SSHing into your server, installing snapd, setting up Certbot, and configuring your server to serve your website over HTTPS. Certbot is a free, open-source tool that automates the process of obtaining and renewing SSL/TLS certificates from Let’s Encrypt.

Step 1: SSH into Your Server

To begin, you’ll need to SSH into your server. If your website is hosted on a server that you can access via SSH, and you have a user account with sudo privileges, connect to your server using the following command:

ssh your_username@your_server_ip

Replace your_username with your actual username and your_server_ip with your server’s IP address.

Step 2: Install Snapd

Snapd is a package manager that allows you to easily install software packages called snaps. These packages are self-contained, ensuring that all dependencies are included.

  1. Update your package list:
   sudo apt-get update
  1. Install Snapd:
   sudo apt-get install snapd
  1. Enable classic snap support (if required):
    Follow any additional instructions provided by Snapcraft to enable classic snap support.

Step 3: Remove Existing Certbot Installations

If you have previously installed Certbot using your OS’s package manager, it’s important to remove it to avoid conflicts with the snap version.

Depending on your OS, run one of the following commands:

  • For Debian/Ubuntu:
  sudo apt-get remove certbot
  • For Fedora:
  sudo dnf remove certbot
  • For CentOS/RedHat:
  sudo yum remove certbot

This ensures that when you run the certbot command, it uses the snap version instead of the one from your OS package manager.

Step 4: Install Certbot via Snap

With snapd installed, you can now install Certbot:

sudo snap install --classic certbot

Step 5: Prepare the Certbot Command

To make sure that the certbot command is easily accessible, create a symbolic link to the /usr/bin directory:

sudo ln -s /snap/bin/certbot /usr/bin/certbot

This command ensures that you can run Certbot from any location in the terminal.

Step 6: Obtain and Install Your SSL Certificate

You can now choose how you’d like to configure HTTPS on your website:

Option 1: Automatically Configure Apache with SSL

If you want Certbot to obtain a certificate and automatically configure Apache to use it, run the following command:

sudo certbot --apache

This command will obtain the certificate and update your Apache configuration to serve your site over HTTPS, all in one step.

Option 2: Manually Configure Apache with SSL

If you prefer to obtain the certificate and configure Apache manually, use the following command:

sudo certbot certonly --apache

This command will only obtain the certificate, leaving the Apache configuration to you.

Step 7: Test Automatic Renewal

Certbot automatically renews your certificates before they expire, using either a cron job or a systemd timer. To ensure this process works correctly, you can perform a dry run:

sudo certbot renew --dry-run

This command simulates the renewal process without making any changes, allowing you to verify that automatic renewal is working properly.

Step 8: Confirm Your HTTPS Setup

Once you’ve installed your SSL certificate, visit your website in a browser using https://yourwebsite.com. Look for the lock icon in the URL bar, which indicates that your site is now being served over HTTPS.

If you encounter any issues during this process, consult the Certbot documentation or reach out to the community for help. Certbot is part of the EFF’s commitment to making encryption accessible to everyone, and they offer resources and support to ensure your setup is successful.

Conclusion

By following these steps, you’ve successfully secured your website with HTTPS using Certbot and Snap. This not only protects your users’ data but also improves your website’s credibility and SEO ranking. Regularly check your SSL certificates and renew them as needed to maintain a secure connection for your users.

If you found this guide helpful, consider supporting the Electronic Frontier Foundation (EFF) and Certbot by donating to help continue their work in promoting online privacy and security.


Tags: SSH, Server Management, Certbot, HTTPS, SSL, Snap, Website Security, Linux, Apache

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *