Home / Configs / Developer tools / SSH config file

SSH config file: example for servers and GitHub

Give servers short names and choose the right key for each.

For OpenSSH on Linux, macOS and Windows 10/11. On Windows the file is C:\Users\YourName\.ssh\config.

The SSH config file lets you type ssh myserver instead of a long command, and tells SSH which key to use for each server. Enter your details below and save the result as ~/.ssh/config.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

You will type: ssh myserver
IP or domain

~/.ssh/config
Host github.com
  User git
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

Host myserver
  HostName 203.0.113.10
  User ubuntu
  Port 22
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes
  ServerAliveInterval 60

How this setup works

Diagram: ssh myserver, then ~/.ssh/config, then Server
ssh myserver (short name) → ~/.ssh/config (finds address and key) → Server (your address)

Step-by-step setup

  1. Make a key: ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519.
  2. Add the public key (~/.ssh/id_ed25519.pub) to GitHub or the server.
  3. Create ~/.ssh/config and paste the config above.
  4. Lock it down: chmod 600 ~/.ssh/config.
  5. Test: ssh myserver (or ssh -T git@github.com for GitHub).

What the important lines mean

Common errors and how to fix them

Permission denied (publickey)
The server does not have your public key, or the wrong key is used. Run ssh -v myserver to see which key is tried.
Bad owner or permissions on config
Run chmod 600 ~/.ssh/config.

Frequently asked questions

Where is the SSH config file?
On Linux and macOS it is ~/.ssh/config. On Windows it is C:\Users\YourName\.ssh\config. If it does not exist, create it.
How do I use different keys for different servers?
Add one Host block per server and set IdentityFile to the key for that server. Keep IdentitiesOnly yes so SSH tries only that key.
Why do I get Permission denied (publickey)?
The server does not have your public key, or SSH is offering a different key. Run ssh -v with your host name to see which key is tried, and add the matching .pub file to the server.

Written for: OpenSSH 9.6, Ubuntu 24.04, macOS 14 · Updated 2026-10-02

Free tools that help

More developer configs

See all 41 config generators