Skip to content

Creating Public/Private Keys

Generating an SSH Key and Copying It to a Host

1. Generate the key (Linux, macOS, and Windows)

The same command works on all three systems:

ssh-keygen -t ed25519 -C "your_comment"

This creates two files:

On Linux and macOS they are saved in ~/.ssh/. On Windows they are saved in %USERPROFILE%\.ssh\.

2. Copy the public key to the host

Linux and macOS:

ssh-copy-id user@host

Windows (PowerShell):

type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh user@host "cat >> ~/.ssh/authorized_keys"

Windows (Command Prompt):

type %USERPROFILE%\.ssh\id_ed25519.pub | ssh user@host "cat >> ~/.ssh/authorized_keys"

3. Connect

ssh user@host

You should now log in without a password.

Notes