SSH Into a Remote Server: The Hosting Admin Checklist
A precise SSH checklist for hosting admins: install OpenSSH only where needed, use Ed25519 keys, copy the public key, and test before hardening.
SSH is one of the first tools a hosting admin learns, but it is also one of the easiest places to build unsafe habits. A clean workflow starts with keys, a known destination, and a rollback path before you tighten server policy.
Table Of Content
- 1. Know what SSH is doing
- 2. Install the server package only where needed
- 3. Use a modern key pair
- 4. Copy the public key, not the private key
- 5. Test before hardening
- 6. Keep an emergency path
- Safe hardening sequence after the first successful SSH login
- Target system: client workstation with OpenSSH
- Target system: remote Ubuntu/Debian SSH server before changing policy
- Target system: remote RHEL-family or cPanel/WHM SSH server before changing policy
- Config target: /etc/ssh/sshd_config or /etc/ssh/sshd_config.d/ include
- Target system: Ubuntu/Debian SSH server after policy change
- Target system: RHEL-family or cPanel/WHM SSH server after policy change
- Target system: remote user account on the SSH server
- Target system: RHEL-family server with SELinux enforcing and keys still rejected
- Client-side SSH hygiene for multiple hosting accounts
- Target system: admin workstation using OpenSSH client
- Target system: admin workstation verifying the remote fingerprint
1. Know what SSH is doing
The OpenSSH manual describes ssh as the command that connects to and logs into a destination such as [user@]hostname, with the user proving identity to the remote machine. OpenSSH ssh(1)
ssh [email protected]
If the server uses a non-default port, pass it explicitly:
ssh -p 2222 [email protected]
2. Install the server package only where needed
On Ubuntu servers that should accept inbound SSH, Ubuntu documents installing OpenSSH Server with sudo apt install openssh-server. Ubuntu Server documentation
sudo apt update
sudo apt install openssh-server
Do not install or expose an SSH daemon on a system that does not need remote administration. On hosting infrastructure, fewer listening services mean fewer things to patch, monitor, and firewall.
3. Use a modern key pair
Ubuntu recommends Ed25519 for SSH-key authentication because of its shorter key size and lower computational requirements, and its example uses ssh-keygen -t ed25519. Ubuntu Server documentation
ssh-keygen -t ed25519 -C "[email protected]"
The OpenSSH ssh-keygen manual lists ed25519 among supported key types for -t. OpenSSH ssh-keygen(1)
4. Copy the public key, not the private key
The Ubuntu man page for ssh-copy-id describes it as a tool that uses locally available keys to authorize logins on a remote machine. Ubuntu ssh-copy-id manpage
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]
Keep ~/.ssh/id_ed25519 private. Only the .pub file is meant to be copied to the server.
5. Test before hardening
Open a second terminal and confirm key-based login works before you disable password authentication or root login. A good basic test is:
ssh -i ~/.ssh/id_ed25519 [email protected]
The OpenSSH manual documents -i identity_file for selecting the private-key file used for authentication. OpenSSH ssh(1)
6. Keep an emergency path
Before editing server SSH policy, make sure you have console access through your host, an existing root-capable session, or another tested admin account. That rule is boring until the first time a typo in sshd_config locks out production access.
The small checklist is enough for most new hosting work: confirm the server should expose SSH, create an Ed25519 key, copy only the public key, test a fresh login, and only then tighten policy.
Safe hardening sequence after the first successful SSH login
This section applies after you have already reached the server once and copied a public key. Before tightening SSH policy, keep a break-glass path open: provider console, WHM terminal, IPMI/KVM, or an existing root-capable SSH session that you do not close. The goal is to prove key login and configuration syntax before disabling password fallback.
Target system: client workstation with OpenSSH
ssh -o PreferredAuthentications=publickey
-o PasswordAuthentication=no
-i ~/.ssh/id_ed25519
[email protected] 'whoami; hostname; id'
This test intentionally refuses password authentication. If it prompts for a password, the key path is not working yet. Fix that before editing server policy. Common causes are copying the private key instead of the .pub file, logging in as the wrong Unix user, using the wrong port, or server-side permissions that cause OpenSSH StrictModes checks to reject the key. The OpenSSH ssh manual documents identity files and authentication options. OpenSSH ssh(1)
Target system: remote Ubuntu/Debian SSH server before changing policy
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +%Y%m%d-%H%M%S)
sudo sshd -t
sudo sshd -T | grep -E '^(passwordauthentication|permitrootlogin|pubkeyauthentication|allowusers)'
Target system: remote RHEL-family or cPanel/WHM SSH server before changing policy
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +%Y%m%d-%H%M%S)
sudo sshd -t
sudo sshd -T | grep -E '^(passwordauthentication|permitrootlogin|pubkeyauthentication|allowusers)'
sshd -t checks syntax. sshd -T prints the effective configuration after defaults and includes are applied. If either command fails, stop and fix the configuration before reload. On cPanel/WHM servers, account-level SSH keys and root SSH policy are separate concerns; cPanel documents account SSH Access and WHM documents root-key and password-authorization controls. cPanel SSH Access WHM Manage root SSH keys WHM SSH Password Authorization Tweak
Config target: /etc/ssh/sshd_config or /etc/ssh/sshd_config.d/ include
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin no
AllowUsers admin
Use AllowUsers only when you know every account that must retain access. A typo there can lock out valid keys. If you need root access for automation, prefer a named admin account with sudo and document the escalation path instead of allowing routine root SSH. The OpenSSH sshd_config manual is the authoritative reference for these directives. OpenSSH sshd_config(5)
Target system: Ubuntu/Debian SSH server after policy change
sudo sshd -t
sudo systemctl reload ssh
Target system: RHEL-family or cPanel/WHM SSH server after policy change
sudo sshd -t
sudo systemctl reload sshd
Do not close the original session yet. Open a new terminal and repeat the public-key-only login test. If it fails on Ubuntu/Debian, check journalctl -u ssh -n 50 --no-pager. If it fails on RHEL-family systems, check journalctl -u sshd -n 50 --no-pager. For permission-related failures, verify the remote account has a private home directory layout OpenSSH will accept.
Target system: remote user account on the SSH server
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Target system: RHEL-family server with SELinux enforcing and keys still rejected
restorecon -Rv ~/.ssh
The successful finish line is specific: a new session logs in with the intended key, password authentication is refused, root login follows the policy you chose, and you still have console access if the next change goes wrong.
Client-side SSH hygiene for multiple hosting accounts
Many lockouts and wrong-server mistakes start on the client, not on the remote server. If you administer several VPS, cPanel, or CloudLinux accounts, put host-specific settings in ~/.ssh/config instead of typing long commands from memory. This keeps usernames, ports, identity files, and jump hosts tied to a named target.
Target system: admin workstation using OpenSSH client
# ~/.ssh/config
Host sxz-prod
HostName example.com
User admin
Port 2222
IdentityFile ~/.ssh/id_ed25519_sxz
IdentitiesOnly yes
ServerAliveInterval 30
After adding the host block, connect with ssh sxz-prod. IdentitiesOnly yes is useful when the client has many keys loaded in an agent; it tells OpenSSH to try the intended key instead of spraying unrelated identities at the server until the server refuses more attempts. Use separate keys for unrelated hosting accounts so one compromised workstation key does not become universal access.
Target system: admin workstation verifying the remote fingerprint
ssh-keygen -l -f ~/.ssh/known_hosts
ssh -o StrictHostKeyChecking=accept-new sxz-prod
For first login to a new server, compare the fingerprint shown by SSH with the provider console or a trusted out-of-band source when available. If a known host key changes unexpectedly, stop and investigate before accepting it. Legitimate rebuilds and IP reassignments can change host keys, but so can interception or DNS mistakes. Treat host-key verification as part of the checklist, not a cosmetic warning.
Featured image: “MacBook Pro backlit keyboard” by Remko van Dokkum, licensed under CC BY 2.0.








No Comment! Be the first one.