SSH and SFTP Create an SSH key on macOS, Linux or Windows

Deutsch

Create an SSH key on macOS, Linux or Windows

Make an Ed25519 key with the ssh-keygen command that comes with macOS, Linux and Windows 10 and 11.

Do this once on each computer you work from. The command is the same in the macOS Terminal, a Linux terminal and Windows PowerShell or cmd.

Steps

  1. Open Terminal (macOS: Applications > Utilities; Linux: your terminal) or PowerShell on Windows (right-click the Start button, choose Terminal or Windows PowerShell).
  2. Type ssh-keygen -t ed25519 -C "laptop" and press Enter. The text after -C is a note for you, such as the computer's name.
  3. Press Enter to keep the suggested file (.ssh/id_ed25519 in your home folder).
  4. Type a passphrase and press Enter, then type it again. It protects the key if your computer is lost.
  5. Show the public key: on macOS pbcopy < ~/.ssh/id_ed25519.pub copies it; on Linux cat ~/.ssh/id_ed25519.pub; in PowerShell Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard; in cmd type %USERPROFILE%\.ssh\id_ed25519.pub | clip.

Result

You have a key pair. The public key, one line starting with ssh-ed25519, is on your clipboard or on the screen.

What to do next

Now add the key to your site.

Warning

The file without .pub is your private key. Never send it, paste it into a website or copy it to a server. Only the .pub file is shared.

An older system that does not know Ed25519? Use ssh-keygen -t rsa -b 4096 instead; the file is then id_rsa.pub.