🔐
blog.cat.ssl

acme.sh: Issuing and Renewing SSL Certificates on a VPS

17.11.2026
← All articles

acme.sh is a client for obtaining free SSL certificates from Let's Encrypt and other certificate authorities that speak the ACME protocol. Its main advantage is that it is pure shell: no Python, no extra libraries, no package manager. That makes it a good fit for old servers, minimal containers and even non-root users. Compared with Certbot it is lighter, and its DNS provider support is much broader.

If your site lives on ordinary shared hosting, you probably don't need acme.sh at all: on sayt.uz hosting, Let's Encrypt certificates are issued from the panel and renew themselves. This guide is for a VPS or your own server where you manage Nginx or Apache by hand.

Installing acme.sh and choosing Let's Encrypt

Installation is a single command. The script copies itself into ~/.acme.sh/, adds an alias and creates a daily cron job. The email address is used to register an account with the CA, so use a real mailbox you actually read.

curl https://get.acme.sh | sh -s email=admin@example.uz
source ~/.bashrc
acme.sh --version

Since version 3.0 the default CA in acme.sh is ZeroSSL, not Let's Encrypt. Both are free, but many people prefer Let's Encrypt for familiarity and documentation. Change the default once and every later command will use it.

acme.sh --set-default-ca --server letsencrypt

Webroot mode for a live site

In webroot mode acme.sh writes a temporary file under .well-known/acme-challenge/ in the site root, and Let's Encrypt fetches it over HTTP on port 80. The web server keeps running, which makes this the safest choice for a production site. The domain's A record must point to this server and port 80 must be reachable from outside.

Say a Tashkent furniture shop runs misol.uz on a VPS with Nginx, with files in /var/www/misol.uz. Issuing one certificate for the bare domain and www looks like this:

acme.sh --issue -d misol.uz -d www.misol.uz -w /var/www/misol.uz

If Nginx proxies every request to an application such as Node.js, the challenge path goes there too and validation fails with a 404. Add a dedicated location that serves challenge files from disk:

location ^~ /.well-known/acme-challenge/ {
    root /var/www/misol.uz;
    default_type "text/plain";
}

Standalone and nginx modes

On a fresh server with no web server yet, standalone mode starts a temporary listener on port 80 and stops it after validation. The port must be free and socat must be installed. The --nginx mode instead patches the Nginx config temporarily and restores it afterwards, which is convenient but can surprise you on complex multi-file setups.

acme.sh --issue --standalone -d misol.uz

DNS API and wildcard certificates

A wildcard such as *.misol.uz requires DNS-01 validation. acme.sh creates a _acme-challenge TXT record, Let's Encrypt reads it, and the record is removed. Ready-made hooks exist for hundreds of DNS providers, for example dns_cf for Cloudflare. Create an API token limited to DNS edit on that one zone instead of handing over a global key.

export CF_Token="cloudflare-api-token"
acme.sh --issue --dns dns_cf -d misol.uz -d '*.misol.uz'

The token is saved to ~/.acme.sh/account.conf on first use, so renewals run unattended. Manual DNS mode exists, but then you must add the TXT record yourself every time, which defeats automation.

Deploying the certificate to Nginx

The most common mistake is pointing Nginx directly at files inside ~/.acme.sh/, whose layout is internal and may change. Use --install-cert to copy files to a stable location and register a reload command. acme.sh remembers this and repeats it after every renewal.

mkdir -p /etc/nginx/ssl
acme.sh --install-cert -d misol.uz \
  --key-file       /etc/nginx/ssl/misol.uz.key \
  --fullchain-file /etc/nginx/ssl/misol.uz.fullchain.pem \
  --reloadcmd      "systemctl reload nginx"

Always reference the fullchain file; serving only the leaf certificate makes some phones and older browsers fail to build the chain.

ssl_certificate     /etc/nginx/ssl/misol.uz.fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/misol.uz.key;

How automatic renewal works

The daily cron job checks every certificate and, by default, renews those older than 60 days, so a 90-day certificate is replaced about a month before expiry. Verify the job and list certificates, then force a renewal once to prove the whole chain works. Recent versions default to ECC keys, so you may need --ecc; check the key type in the --list output.

crontab -l | grep acme
acme.sh --list
acme.sh --renew -d misol.uz --force --ecc

Troubleshooting

If issuance fails, rerun with --debug 2 and read ~/.acme.sh/acme.sh.log. Usually the cause is simple: DNS has not propagated, port 80 is firewalled, or the domain points elsewhere. Test against the --staging server while experimenting to avoid hitting Let's Encrypt rate limits, and enable self-updates with acme.sh --upgrade --auto-upgrade.

dig +short misol.uz A
curl -I http://misol.uz/.well-known/acme-challenge/test

Related articles

🔐 ERR_CERT_COMMON_NAME_INVALID: when the SSL certificate name does not match 🔒 SSL certificate lifetime drops to 47 days: what changes 🚨 SSL Errors: Fixing ERR_CERT_AUTHORITY_INVALID and Other Issues 🔐 HSTS Strict-Transport-Security and preload list — complete guide for Chrome and Firefox
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓