An interactive bash script to easily manage SSL certificates for Marzneshin VPN panel using either acme.sh
or certbot
.
- π Two Certificate Methods: Choose between
acme.sh
andcertbot
- π§ Email Memory: Remembers and suggests your last used email
- π Domain Validation: Validates domain format before processing
- π Custom Paths: Choose where to store your certificates
- π Certificate Registry: Track all created certificates
- ποΈ Certificate Management: List and remove existing certificates
- π¨ Colorized Output: Easy-to-read interface with colors
- β
Domain-Named Files: Certificates named after your domain (e.g.,
example.com.crt
)
β οΈ Important: This script is interactive and requires user input. Avoid usingcurl | bash
as it doesn't support interactive prompts properly.
# Download the script
curl -O https://raw.githubusercontent.com/raminrez/cert-scripts/main/ssl-cert-manager.sh
# Make it executable
chmod +x ssl-cert-manager.sh
# Review the script (recommended)
cat ssl-cert-manager.sh
# Run the script
sudo ./ssl-cert-manager.sh
# Download and run in one command
curl -sSL https://raw.githubusercontent.com/raminrez/cert-scripts/main/ssl-cert-manager.sh -o ssl-cert-manager.sh && chmod +x ssl-cert-manager.sh && sudo ./ssl-cert-manager.sh
# Clone the repository
git clone https://github.com/raminrez/cert-scripts.git
cd cert-scripts
# Make script executable
chmod +x ssl-cert-manager.sh
# Run the script
sudo ./ssl-cert-manager.sh
- Ubuntu/Debian based system
- Root access (script must run with sudo)
- Internet connection for downloading certificates
- Domain pointing to your server's IP address
Note: The script automatically installs all required dependencies including:
curl
- For downloading tools and certificateswget
- For file downloadssocat
- Required for acme.sh standalone modecron
- For automatic certificate renewalscertbot
- Installed only when using certbot method
-
Run the script as root:
sudo ./ssl-cert-manager.sh
-
First run will automatically:
- Update system packages
- Check and install required dependencies
- Verify port availability (80 and 443)
-
Choose from the main menu:
1
- Install SSL Certificate using acme.sh2
- Install SSL Certificate using certbot3
- List existing certificates4
- Remove certificate5
- System certificate cleanup6
- Update script to latest version7
- Exit
-
Follow the interactive prompts:
- Enter your email (or use the suggested one)
- Enter your domain name
- Choose output path (or use default:
/var/lib/marzneshin/certs
)
The script supports several command line options for non-interactive usage:
# Show version information
sudo ./ssl-cert-manager.sh --version
# Show help message
sudo ./ssl-cert-manager.sh --help
# Update script to latest version
sudo ./ssl-cert-manager.sh --update
# Run in interactive mode (default)
sudo ./ssl-cert-manager.sh
To quickly update the script without going through menus:
# Download and update in one command
curl -O https://raw.githubusercontent.com/raminrez/cert-scripts/main/ssl-cert-manager.sh && chmod +x ssl-cert-manager.sh && sudo ./ssl-cert-manager.sh --update
- More lightweight and flexible
- Better for automation and renewals
- Supports multiple CA providers
What it does:
- Downloads and installs acme.sh
- Sets Let's Encrypt as default CA
- Registers your email with Let's Encrypt
- Issues certificate for your domain
- Installs certificate to specified location
- Official Let's Encrypt client
- Well-established and widely used
- Good community support
What it does:
- Installs certbot package (if not already installed)
- Issues certificate for your domain
- Copies certificates to specified location
After successful certificate creation, you'll get:
yourdomain.com.crt
- Certificate fileyourdomain.com.key
- Private key file
After getting your certificates, update your Marzneshin configuration:
-
Edit the environment file:
nano /etc/opt/marzneshin/.env
-
Add/update these lines:
# For default path (/var/lib/marzneshin/certs) UVICORN_SSL_CERTFILE=/var/lib/marzneshin/certs/yourdomain.com.crt UVICORN_SSL_KEYFILE=/var/lib/marzneshin/certs/yourdomain.com.key # Or for custom path UVICORN_SSL_CERTFILE=/your/custom/path/yourdomain.com.crt UVICORN_SSL_KEYFILE=/your/custom/path/yourdomain.com.key
-
Restart Marzneshin:
marzneshin restart
The script maintains a registry of all certificates created, showing:
- Domain name
- Method used (acme.sh or certbot)
- Certificate and key file paths
- Creation timestamp
- File existence status
Safely remove certificates and clean up:
- Deletes certificate and key files
- Removes entry from registry
- Confirms before deletion
- Certificates:
/var/lib/marzneshin/certs/
(default) or your custom path - Script Config:
~/.ssl-cert-manager/
- Email Memory:
~/.ssl-cert-manager/last_email
- Certificate Registry:
~/.ssl-cert-manager/cert_registry
-
"This script must be run as root"
- Solution: Use
sudo ./ssl-cert-manager.sh
- Solution: Use
-
"Invalid domain format"
- Solution: Ensure domain format is correct (e.g.,
example.com
, nothttps://example.com
)
- Solution: Ensure domain format is correct (e.g.,
-
Certificate issuance fails
- Ensure domain points to your server's IP
- Check if port 80 is available
- Verify no firewall blocking
-
Permission denied errors
- Ensure script is executable:
chmod +x ssl-cert-manager.sh
- Run with sudo for system operations
- Ensure script is executable:
- Port 80: Required for domain validation (both methods)
- Port 443: Required for HTTPS after certificate installation
Before running the script, ensure:
- Your domain's A record points to your server's IP
- Port 80 is accessible from the internet
- No other web server is using port 80
- Always review scripts before running with sudo
- Keep your certificates secure and backed up
- Regularly renew certificates (Let's Encrypt certificates expire every 90 days)
- Monitor certificate expiration dates
# Manual renewal
~/.acme.sh/acme.sh --renew -d yourdomain.com
# Auto-renewal is typically set up automatically
# Manual renewal
certbot renew
# Test auto-renewal
certbot renew --dry-run
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues:
- Check the troubleshooting section above
- Ensure all requirements are met
- Open an issue on GitHub with details about your problem
- acme.sh - A pure Unix shell script ACME client
- Certbot - Official Let's Encrypt client
- Marzneshin - Unified GUI Censorship Resistant Solution