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 ↗

Tip: ssh-keygen -c changes the comment on an SSH key

Network and access
~/tips/tip-ssh-keygen-c-change-comment

ssh-keygen -c -C "work laptop 2026" -f ~/.ssh/id_ed25519

Rename the label on an existing key so you can tell keys apart later.

The comment at the end of a public key is what you read in authorized_keys months later. If it says user@localhost, you have no idea which machine it belongs to. You can fix it without making a new key.

Give the new comment with -C and the key with -f:

ssh-keygen -c -C "work laptop 2026" -f ~/.ssh/id_ed25519

It prints the old comment and applies the new one to both the private key and the .pub file. If the key has a passphrase, it asks for it, because the comment is stored inside the private key too.

The key itself does not change, so the fingerprint stays the same and every server that already has it keeps working. Only the text after the key differs.

That is also the catch. The servers still hold the old line with the old comment. If you want the new label there, replace the line in each authorized_keys yourself, or copy the key again with ssh-copy-id and remove the old duplicate.

My suggestion for comments: device name plus year, like work laptop 2026. When a laptop is gone, a search of all authorized_keys files for that name tells you exactly which lines to delete.

Further reading: ssh-keygen man page

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link