SSH config file: example for servers and GitHub
Give servers short names and choose the right key for each.
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.
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 60How this setup works
Step-by-step setup
- Make a key: ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519.
- Add the public key (~/.ssh/id_ed25519.pub) to GitHub or the server.
- Create ~/.ssh/config and paste the config above.
- Lock it down: chmod 600 ~/.ssh/config.
- Test: ssh myserver (or ssh -T git@github.com for GitHub).
What the important lines mean
- IdentitiesOnly yes uses only the key you named, which avoids “too many authentication failures”.
- ServerAliveInterval 60 stops idle connections from dropping.
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.
Free tools that help
- chmod calculatorTick read, write and execute for owner, group and others to get the chmod number, symbolic form and command. Or type 755 and see what it means.
More developer configs
- .gitconfig setupSet your name, email, default branch and shortcuts once.
- .env file exampleCreate a .env file for your app: port, database address and a secret key.
- VS Code settings.jsonSet font, tab size, format on save and theme in your VS Code settings.
- .bashrc and .zshrc aliasesAdd handy shortcuts and settings to your terminal.
- .gitignore fileTick your languages and tools to get a .gitignore that keeps build files and secrets out of Git.
- .editorconfig fileMake every editor on your team use the same indent, line endings and encoding.