Full Byte Developer.

SSH keys for developers

Generate an Ed25519 key with ssh-keygen, protect the private half, and install only the public .pub file on servers.

Published here , updated · 4 sources

SSH public-key login uses a key pair from ssh-keygen: keep the private file secret, install only the .pub line on the remote [1]. Git remotes and VPS shells share the same idea with different authorized_keys layouts. Pair key files with a short Host alias in SSH config so you stop pasting four flags every deploy.

Generate an Ed25519 user key

OpenSSH: with no arguments, ssh-keygen generates an Ed25519 key [1]. Explicit form:

bash
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519

The tool writes the private key to the path you chose and the public key beside it with .pub appended [1]. It asks for a passphrase; empty means none (required empty for host keys; for user keys prefer a real passphrase on laptops) [1]. Default private-key format is OpenSSH-specific and preferred for protection at rest [1].

Demo under /tmp (empty passphrase for teaching only):

bash
ssh-keygen -t ed25519 -N '' -f /tmp/ssh_demo_key -C 'draft-demo' -q
ssh-keygen -l -f /tmp/ssh_demo_key.pub

Captured output:

text
256 SHA256:BDCKxcNdiqyXrjzYshZvBPWt+9PVkUgdw5lBHZ89HfI draft-demo (ED25519)

The 256 is bit length for Ed25519 public material in that listing format [1]. Delete demo keys after teaching; never reuse empty-passphrase keys on real hosts.

Draw user key versus host key

your laptop id_ed25519 PRIVATE never upload id_ed25519.pub PUBLIC remote server authorized_keys one public line per user key host key is not user key First connect stores the server host key in known_hosts on the laptop [1][2].

User keys prove who you are. Host keys prove which server you reached. Mixing them up breaks rotation plans.

Install only the public half

bash
cat ~/.ssh/id_ed25519.pub

One line: algorithm, base64 blob, optional comment [1]. Append that line to ~/.ssh/authorized_keys on the server, or paste it into GitHub or GitLab SSH settings. Keep ~/.ssh mode 700 and private keys mode 600 so OpenSSH does not refuse loose permissions [1][2].

ssh-copy-id automates append when password login still works once. For Git hosting, the UI stores the public line; the private file never leaves your machine.

HTTPS protects web APIs in browsers (what is HTTPS). SSH protects interactive shells and [email protected] style remotes. Different transports; both need key hygiene.

Use the agent and multiple keys

ssh-agent holds decrypted private keys in memory for a session. ssh-add loads keys after you enter the passphrase [1]. Multiple projects may use -i or better, a Host block:

text
Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work
  IdentitiesOnly yes

Host aliases beat swapping default key names when one laptop joins work and personal GitHub. The full Include and first-value-wins story is on SSH config.

Rotate when the private key is at risk

There is no recovery for a lost passphrase: generate a new key and replace public keys on every host [1]. Change a passphrase later with ssh-keygen -p [1]. If a private file was copied to chat, email, or a public repo, treat it as burned: new keypair, new authorized_keys everywhere, audit git history.

Host key changes after reinstalling a VPS trigger REMOTE HOST IDENTIFICATION HAS CHANGED. Verify out-of-band (console fingerprint) before accepting [1].

Test GitHub SSH before you blame the repo

bash
ssh -T [email protected]

Success often prints a greeting with your username; failure prints Permission denied (publickey). That test exercises user keys and known_hosts, not your HTTPS session to the website (what is HTTPS).

When no key is loaded, the command exits non-zero with permission denied. After ssh-add, the same command should authenticate if the matching .pub line is on the account. Read the message for auth success versus failure; wording on the server side changes over time.

File layout OpenSSH expects

Default paths under ~/.ssh/ include id_ed25519, id_ed25519.pub, known_hosts, and optional config [1]. authorized_keys lives on servers you log into, not on the laptop. known_hosts accumulates host keys per HostName and port. Deleting it forces re-verification on next connect.

Comments in the public key (-C flag) are labels for humans only; the server ignores them for auth [1]. Keep comments honest (you@work-laptop-2026) when you rotate yearly.

Ed25519 versus legacy RSA

OpenSSH defaults new keys to Ed25519 [1]. Older docs still mention ssh-keygen -t rsa -b 4096. RSA remains valid where policy requires it. New developer keys should start Ed25519 unless a vendor doc names another type. If GitHub rejects an old RSA signature path, migrate with GitHub RSA SSH key cut-over.

Forwarding stays a separate checklist

SSH can forward local ports or agent access with -L, -R, and -A. Agent forwarding lets a remote host use keys already loaded in your local agent. That is convenient on jump hosts and risky on untrusted machines. Leave it off unless your runbook documents the threat model [2]. Hardware security keys (FIDO/U2F) are a different stack from file-based SSH keys; when a doc mentions WebAuthn for SSH, read that vendor path separately from ssh-keygen [2].

Audit keys on a schedule

List fingerprints you expect on each host and in each Git hosting account. After laptop loss or contractor offboarding, remove the matching line from authorized_keys and from Git hosting settings the same day [1]. Yearly rotation is a reasonable default for developer laptops even when nothing leaked: generate a new Ed25519 key, install the public line everywhere you still need access, then delete the old private file.

Comments in the public key help that audit. A comment like you@work-laptop-2026 tells you which machine produced the line when five keys sit on one GitHub account [1].

Certificate-based auth (name only)

Some enterprises issue SSH user certificates signed by a CA instead of raw authorized_keys lines per host. That is still public-key cryptography, but rotation and expiry move to the CA workflow [2]. Personal GitHub and VPS paths in this article stay with the classic authorized_keys line. If your company mandates certificates, follow their runbook; do not mix a CA identity with a home lab key in the same Host block without reading both docs [2].

Mistakes that burn keys

Committing id_rsa or id_ed25519 without .pub in a repository. Scanners and bots harvest them.

Pasting the private key into a cloud server's "SSH key" UI. Those fields expect the public line only.

Using chmod 777 on ~/.ssh because login failed. OpenSSH refuses loose permissions on some platforms [1].

Sharing one team key file in a password manager instead of per-person keys. You lose attribution and easy revocation.

Skipping host key verification on first connect in scripts (StrictHostKeyChecking=no everywhere). That opens MITM paths on untrusted networks [1][2].

Treating HTTPS client certs and SSH user keys as interchangeable. TLS certs authenticate servers for HTTP; SSH user keys authenticate you to sshd or git remotes (what is HTTPS).

Leaving an empty-passphrase private key on a laptop that travels. Disk encryption helps; a passphrase on the key still matters when the file is copied out [1].

What you have now

A sourced Ed25519 path from generate to fingerprint, plus a clear split between private file, public line, and host keys. Put the public line on remotes, keep the private file mode 600, and alias hosts in SSH config so deploy scripts stop carrying four flags [1][2].

Browse the Dev tools topic.

Send this to the friend who still emails private key files as attachments.

Circular dark port with a glowing teal center on the left facing a matte cube with a glowing gold disk on the right, linked by curved and straight teal and gold arrows on a dark grid floor.
Public material travels to the remote; the private file stays on your laptop and never belongs in a paste field.

Keep this guide

By Full Byte Developer

Filed under Dev tools, Security

Questions about this guide

Which key type should I create by default?

OpenSSH ssh-keygen: invoked with no arguments it generates an Ed25519 key. Prefer -t ed25519 when you set the type explicitly.

What do I copy to GitHub or a VPS?

Only the public key file (same name with .pub). Never paste or commit the private key.

Do I need a passphrase?

ssh-keygen asks for one. A passphrase encrypts the private key at rest. Host keys must be empty; user keys should use a real passphrase when the laptop can be lost.

Can I recover a forgotten passphrase?

No. OpenSSH: there is no way to recover a lost passphrase. Generate a new key and replace the public key everywhere.

Why does ssh ask about host key fingerprint?

First connect stores the server's host key. Later connects detect mismatches, which may mean DNS hijack or a rebuilt server.

Sources

Next in this stack