How to Generate an SSH Key on Linux

With ed25519 (today's recommended option) and copying it to a remote server with ssh-copy-id.

Intermediate 1 min read Published on 2026 By Equipo SolucionaPC

An SSH key lets you connect to another machine without typing a password every time — more convenient and, well managed, more secure.

ssh-keygen -t ed25519 -C "your_email@example.com"
  • Press Enter to accept the default location (~/.ssh/id_ed25519).
  • It will ask for a passphrase — optional, but recommended as an extra security layer.

Why ed25519 and not RSA? It's faster to generate and verify, more resistant to brute-force attacks, and produces shorter keys. Only use RSA (with ssh-keygen -t rsa -b 4096) if you need to connect to a very old system that doesn't support ed25519.

Result: two files

  • id_ed25519 — your private key. Never share it with anyone.
  • id_ed25519.pub — your public key. This one does get shared, it's the one you install on the remote server.

Copying the public key to the remote server

ssh-copy-id user@remote-server

Asks for your password one last time, and installs your public key on the server — from then on, you'll be able to connect without a password.

Warning: never share or upload your private key (the file without .pub) anywhere. If someone gets hold of it, they can impersonate you on any server where you've installed the corresponding public key.

Frequently asked questions

What's the difference between the public and private key?

The private one always stays on your machine, never shared. The public one (with .pub extension) is the one you install on each server you want to connect to, and it's safe to share.

Do I need a passphrase for the key?

It's optional but recommended — it adds an extra security layer in case someone gets hold of your private key, without which they still couldn't use it.

Why ed25519 instead of RSA?

It's faster, more resistant to brute-force attacks, and generates shorter keys. RSA remains valid mainly for compatibility with very old systems.

Share: