SSH keys provide a secure, convenient alternative to password-based authentication when connecting to your server. Instead of entering a password each time you log in, SSH keys use a pair of cryptographic keys — one private (kept on your local machine) and one public (stored on the server) — to verify your identity automatically.
This guide covers how to generate SSH keys, add them to your Data Mammoth account and servers, and manage them effectively.
Why Use SSH Keys?
SSH key authentication offers several advantages over password-based login:
- Stronger security — SSH keys are virtually impossible to brute-force, unlike passwords.
- Convenience — No need to type a password for every connection.
- Automation friendly — Scripts, CI/CD pipelines, and tools can connect without interactive password prompts.
- Auditability — Different keys can be used for different team members, making it easy to track access.
Generating an SSH Key Pair
On macOS and Linux
Open your terminal and run:
ssh-keygen -t ed25519 -C "[email protected]"When prompted:
~/.ssh/id_ed25519) or specify a custom path.This creates two files:
~/.ssh/id_ed25519— Your private key. Never share this.~/.ssh/id_ed25519.pub— Your public key. This is what you add to servers.
On Windows
If you use Windows 10/11 with OpenSSH installed, open PowerShell and run the same command:
ssh-keygen -t ed25519 -C "[email protected]"If you prefer a graphical tool, PuTTYgen can generate SSH keys in PuTTY's format, which can then be converted to OpenSSH format.
Key Type Recommendations
| Key Type | Recommendation |
|---|---|
| ed25519 | Recommended. Modern, fast, and secure. |
| RSA (4096-bit) | Good alternative if ed25519 is not supported. Use ssh-keygen -t rsa -b 4096. |
| RSA (2048-bit) | Minimum acceptable. Consider upgrading to 4096-bit or ed25519. |
| DSA | Deprecated. Do not use. |
| ECDSA | Acceptable but ed25519 is generally preferred. |
Adding SSH Keys to Your Data Mammoth Account
You can store SSH keys in your Data Mammoth account so they are automatically available when provisioning new servers.
cat ~/.ssh/id_ed25519.pubWhen you order a new server, you can select which SSH keys to install during the provisioning process.
Adding SSH Keys to an Existing Server
Via the Dashboard
Via the Command Line
Connect to your server with your current authentication method and add the public key manually:
# Create the .ssh directory if it does not exist
mkdir -p ~/.ssh
chmod 700 ~/.sshAdd the public key to authorized_keys
echo "ssh-ed25519 AAAA... [email protected]" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keysReplace the key content with your actual public key.
Using ssh-copy-id
The easiest command-line method to install your key on a server:
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]This copies your public key to the server's ~/.ssh/authorized_keys file automatically.
Removing an SSH Key
From Your Data Mammoth Account
Removing a key from your account does not automatically remove it from servers where it was already installed.
From a Server
Connect to the server and edit the authorized keys file:
nano ~/.ssh/authorized_keysDelete the line containing the key you want to remove, save, and exit.
Managing Multiple SSH Keys
If you use different keys for different purposes, configure your SSH client to use the correct key for each server:
Create or edit ~/.ssh/config:
Host my-vps HostName 203.0.113.10 User root IdentityFile ~/.ssh/id_ed25519_datamammoth
Host staging-server HostName 203.0.113.20 User deploy IdentityFile ~/.ssh/id_ed25519_staging
Then connect using the alias:
ssh my-vpsTroubleshooting SSH Key Issues
"Permission denied (publickey)"
This means the server rejected your key. Common causes:
~/.ssh/authorized_keys on the server.chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keysroot vs. a regular user).ssh-add -l.Key Not Being Offered
If SSH is not trying your key, specify it explicitly:
ssh -i ~/.ssh/id_ed25519 [email protected]Or add it to your SSH agent:
ssh-add ~/.ssh/id_ed25519What to Do Next
- SSH Key Best Practices — Advanced security recommendations for SSH keys.
- Initial Server Setup — Ubuntu 22.04/24.04 — Secure your server from the start.
- Using the Web Console (VNC/NoVNC) — Access your server when SSH is not working.
- Enable 2FA — Protect Your Account — Add another layer of account security.