Skip to main content
An SSH config file stores your connection details so you can type ssh web instead of ssh -p 2222 -i ~/.ssh/id_ed25519 alex@203.0.113.10. Create ~/.ssh/config on your own computer (C:\Users\<you>\.ssh\config on Windows) and add a Host web block with HostName, User, Port and IdentityFile. The same alias works with scp, sftp and rsync.

Before you start

SSH config file example

With this file, ssh web connects to 203.0.113.10 on port 2222 as alex with your Ed25519 key. ssh db first connects to web and jumps from there to a server on a private network.

What each setting does

How to create the SSH config file

Paste your Host blocks, save with Ctrl+O, exit with Ctrl+X, then lock the file down:

Why order matters

For each setting, SSH uses the first value it finds (ssh_config manual). Put specific Host blocks at the top and the catch-all Host * block at the bottom. If Host * sets User root above your Host web block, web would log in as root.

How to check it worked

ssh -G prints the settings SSH would use for a host, without connecting:
Then connect:
The alias also works for file transfers:

Frequently asked questions

Can I use wildcards in Host?

Yes. * matches any characters and ? matches one, so Host *.example.com covers every subdomain. A pattern starting with ! excludes a host.

SSH says “Bad owner or permissions on ~/.ssh/config”. How do I fix it?

The file must not be writable by other users. On macOS and Linux run chmod 600 ~/.ssh/config.

Can I split the file into several files?

Yes. Add Include config.d/* near the top of ~/.ssh/config and put one file per project in ~/.ssh/config.d/. Relative paths are read from ~/.ssh.

Does VS Code Remote-SSH use this file?

Yes. Visual Studio Code’s Remote-SSH extension reads your SSH config and lists each Host as a target.

VPS and dedicated server guides

Every guide in this section.

Create and use SSH keys

Make the key you point IdentityFile at.

Change the SSH port

Then save it as Port here.

Copy files with scp and rsync

Use your aliases for transfers.

Keep sessions running

tmux and screen.

Checked against the official OpenSSH ssh_config manual on 4 November 2026; the example file was tested with ssh -G, ssh, scp and sftp using OpenSSH 9.6 on Ubuntu 24.04 LTS. The Windows steps were not tested.

Need Extra Help?

If you encounter any issues, our support team is ready to assist:

Save on Your Hosting

Ready to upgrade your hosting? Use code KB20 at checkout for 20% off your first order!

Last Updated: November 2026