brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Guide: set up SSH keys and a ~/.ssh/config so you can type ssh nas and nothing else

set up SSH keys and a ~/.ssh/config so you can type ssh nas and nothing else

Guide ssh

7 steps 4 min read

The first thing I set up on any new machine is SSH keys, before Docker or a dashboard. A password you type ten times a day is a password you will eventually reuse, and a key with a good ~/.ssh/config file turns ssh [email protected] into ssh nas. Here is the setup I would give anyone who runs a home server, step by step, with the one trap that locks people out.

Time
4 min
Steps
7
Updated
19 Nov 2026

You will learn

  • Make a key
  • Put the public key on the server
  • Stop typing the address: ~/.ssh/config
  • Do not retype the passphrase all day
  • Hop through another machine

What you need

Any computer with OpenSSH (macOS, Linux, or Windows 10 and later have it built in) and a server you can already log in to with a password. Everything below is plain OpenSSH, so it works the same for an Unraid box, a VPS or a Raspberry Pi.

Step 1 of 7: Make a key

Ed25519 is the sensible default today: short keys, fast, supported everywhere recent. Give the key a passphrase. That way a stolen laptop is not a stolen server.

ssh-keygen -t ed25519 -C "macbook"

Accept the default location (~/.ssh/id_ed25519). The file without .pub is the private key and never leaves your machine. The -C text is only a label so you can tell keys apart later.

Step 2 of 7: Put the public key on the server

ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

It asks for your password one last time and appends the key to ~/.ssh/authorized_keys on the server. No ssh-copy-id on your system? Paste the contents of the .pub file into that file by hand. Then check that it works before you touch anything else:

ssh [email protected]

If it asks for your key passphrase instead of the server password, it worked.

Step 3 of 7: Stop typing the address: ~/.ssh/config

This is the part I would do first. One small file turns a long command into a short name:

Host nas
    HostName 192.168.1.10
    User root
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Host vps
    HostName vps.example.com
    User jordi
    Port 2222

Now ssh nas does the whole thing, and scp, rsync and sftp understand the same names. IdentitiesOnly yes tells ssh to offer only the key you named. Without it, an agent with many keys can offer them one by one, and servers hang up after a few failed tries (the default limit is six, MaxAuthTries).

Step 4 of 7: Do not retype the passphrase all day

Let the agent hold the unlocked key. On a Mac this line in the config does it, and the macOS keychain remembers the passphrase:

Host *
    AddKeysToAgent yes
    UseKeychain yes

UseKeychain is an Apple addition to OpenSSH. On Linux, drop that line (a stock OpenSSH there will complain about the unknown option) and keep AddKeysToAgent yes. If you want the config to work on both, add IgnoreUnknown UseKeychain above it.

Step 5 of 7: Hop through another machine

If one machine is reachable and the rest hide behind it, ProxyJump saves you a manual double login:

Host inner
    HostName 10.0.0.5
    User jordi
    ProxyJump vps

ssh inner now connects to vps first and tunnels through it. Your keys stay on your own machine the whole time.

Step 6 of 7: When it does not work

  • Run ssh -v nas. It prints which keys it tries and where the server says no.
  • Permissions matter. The server refuses keys if the files are too open: chmod 700 ~/.ssh, chmod 600 ~/.ssh/authorized_keys and chmod 600 ~/.ssh/id_ed25519.
  • Server side, check the log (journalctl -u ssh on Debian and Ubuntu, journalctl -u sshd on most others). It says exactly why a key was rejected.

Step 7 of 7: Only after it works: turn passwords off

Do this last, and keep your current session open while you test in a second terminal. Otherwise one typo locks you out. On the server, set PasswordAuthentication no in /etc/ssh/sshd_config (a file in /etc/ssh/sshd_config.d/ can override it, so check there too), then validate and reload:

sudo sshd -t
sudo systemctl reload ssh

The service is called sshd on some distributions. On Unraid the SSH settings live under Settings, Management Access, and the root key goes in /root/.ssh/authorized_keys. I have not tested that route for this guide, so check the Unraid docs for how it persists across reboots before you rely on it.

Further reading

Link