Comprehensive VPS Infrastructure Security: Deploying SSH Certificate Authority with Step CA
Guide to deploying an SSH Certificate Authority (CA) system using Step CA to secure VPS infrastructure, replacing traditional SSH password and key authentication methods.
Image credit: WebTechExperts · Pixabay Content License
Introduction to SSH Certificate Authority and Step CA
In the context of increasingly stringent network security requirements, replacing traditional SSH authentication methods (passwords or manually managed SSH keys) with an SSH Certificate Authority (CA) system is a critical advancement. SSH CA enables centralized access control for VPS servers, automates certificate issuance and revocation, reduces risks associated with manual key management, and enhances overall security integrity.
Step CA is a modern, open-source certificate authority designed for fast, easy, and secure deployment. With a RESTful API interface, integration with tools like Vault, and support for token-based authentication, Step CA is an ideal choice for building an automated, reliable, and scalable SSH authentication system on VPS infrastructure.
Setting Up Step CA on VPS
To deploy Step CA, you need a VPS running Ubuntu 20.04/22.04 or equivalent. Below are the basic steps to install and configure Step CA:
1. Install Step CA
Run the following commands on the VPS (main server):
# Download and install Step CA
curl -s https://api.github.com/repos/smallstep/certificates/releases/latest | grep browser_download_url | cut -d '\"' -f 4 | wget -i -
tar -xzf smallstep-ca-linux-amd64-*.tar.gz
sudo mv smallstep-ca /usr/local/bin/
sudo chmod +x /usr/local/bin/smallstep-ca
2. Initialize CA and Generate Root Certificate
Execute the following command to initialize the internal CA:
sudo smallstep ca init \
--name "My Step CA" \
--dns "ca.example.com" \
--address "0.0.0.0:443" \
--provisioner "admin" \
--password-file /tmp/password.txt
After completion, Step CA will generate root certificates and required configuration. Note: You can further customize security settings using options like notAfter, provisioner, and token.
3. Configure SSH to Use CA
On the VPS server, edit the /etc/ssh/sshd_config file:
# Enable SSH certificate authentication
PubkeyAuthentication yes
AuthorizedKeysCommand /usr/local/bin/step-ca-ssh-key-auth %u %h
AuthorizedKeysCommandUser nobody
Restart the SSH service:
sudo systemctl restart ssh
Managing Certificates and User Authentication
Step CA provides an API and CLI interface to issue SSH certificates to users or servers. Users can request certificates using tokens, and Step CA will issue time-limited certificates.
1. Create Authentication Token
# Generate a token valid for 1 hour
step ca token --provisioner admin --not-after 1h
This token can be used to issue certificates for users or servers.
2. Issue SSH Certificate
Users or servers can use the token to obtain an SSH certificate:
step ca certificate --provisioner admin --not-after 1h user-ssh-cert
The generated certificate can be used to log in to the VPS without manually managing SSH keys.
Testing and Verification
To verify the deployment, perform the following steps:
- Log in to the VPS using the issued certificate.
- Run the command:
ssh -i ~/.step/certs/user-ssh-cert [email protected] - Verify that the certificate is valid and authentication succeeds.
Troubleshooting
If authentication fails, check the following:
- Whether the certificate has expired.
- Whether the SSH CA is running and listening on port 443.
- Whether the
/etc/ssh/sshd_configfile is correctly configured. - Whether the path to
AuthorizedKeysCommandis correct.
References
- Ultimate SSH Security: Guide to Configuring YubiKey FIDO2/U2F Hardware Authentication for VPS
- Deploy Vaultwarden for Enterprise with Maximum Security Using End-to-End HTTPS via Let's Encrypt
- Network Security & 99.98% SLA Infrastructure at DPTCloud
Deploying an SSH Certificate Authority with Step CA enables a secure, automated, and manageable VPS infrastructure. This solution is ideal for enterprises requiring high security and strict access control.
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
