← Knowledge Base
LinuxReference note1 min read · updated 2026-11-27

SSH keys and a ~/.ssh/config that saves typing

Create an ed25519 key, install it on a server, and use a config file for host aliases, ports and keys.

sshkeyssecurity
ssh-keygen -t ed25519 -C "laptop"             # creates ~/.ssh/id_ed25519 and .pub
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server
ssh user@server

If you cannot use ssh-copy-id, append the public key to ~/.ssh/authorized_keys on the server (mode 600; the .ssh directory 700).

# ~/.ssh/config
Host myserver
    HostName server.example.org
    User ubuntu
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Then ssh myserver, scp file myserver:~/ and rsync -av dir/ myserver:dir/ all work with the alias. Protect the private key with a passphrase and ssh-agent. Never copy a private key to a server or paste it anywhere.