Tutorials · DevOps & Containers
How to Use SSH Keys Instead of Passwords for Network Devices and Servers
Passwords can be guessed, phished and reused. Create an SSH key pair, install the public key on gateways, edge servers and Linux hosts, then turn password logins off.
Before you start
- A laptop with OpenSSH (built into Windows 10/11, macOS and Linux)
- Admin access to the device or server
- A second session open while you test, so you cannot lock yourself out
Step by step
Create a key pair
Ed25519 keys are short, fast and strong. Protect the private key with a passphrase: it never leaves your laptop.
ssh-keygen -t ed25519 -C "alice@company-noc" # saved to ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public)
Install the public key
Copy only the .pub file to the server. On devices without ssh-copy-id, paste the key into the admin page or into ~/.ssh/authorized_keys.
ssh-copy-id -i ~/.ssh/id_ed25519.pub admin@10.1.10.20Test key login
Open a new terminal and log in. You should be asked for the key passphrase, not the account password.
ssh -i ~/.ssh/id_ed25519 admin@10.1.10.20Turn off password logins
On Linux hosts and NavEdge edge servers, disable password and root logins in sshd_config, check the syntax and reload.
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/; s/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config sudo sshd -t && sudo systemctl reload ssh
Use an SSH agent
Load the key once per session instead of typing the passphrase for every device.
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
Remove keys when people leave
Every engineer gets their own key. Delete their line from authorized_keys on every host when they change role or leave.
Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.
Pro tips
- Never share one private key between engineers.
- Back up your private key in a password manager or hardware token, not in email or chat.
- Hardware security keys (FIDO2) can hold SSH keys too: ssh-keygen -t ed25519-sk.
FAQ
Frequently asked questions
Is RSA still OK?
RSA 3072/4096-bit keys are fine where Ed25519 is not supported. Avoid RSA 1024 and DSA keys.
What if I lose my private key?
Log in with another admin key or the local console, remove the old public key and install a new one.
Keep learning
Related guides
Secure switch and router management
Read more →Two-factor authentication for admin accounts
Read more →How to Reach Remote Sites Safely With an SSH Jump Host
Do not expose SSH on every device. Put one hardened jump host (bastion) in front of the management network and reach everything else through it.
Read more →How to Open a Device Web Page Through an SSH Tunnel
Reach the web interface of a switch, NVR or container on a remote site without opening a firewall port: forward it through SSH.
Read more →Docker Basics on a NavEdge Edge Server: Run Your First Container
NavEdge edge servers run on-site applications in Docker containers. Learn the five commands you need: pull, run, ps, logs and restart policies.
Read more →Stuck on a step?
Ask Navijin technical support or an authorised partner for help with your configuration.