> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SSH Config File Example: Shortcuts for Your Servers

> SSH config file example: add a Host block with HostName, User, Port and IdentityFile to ~/.ssh/config, then connect with ssh web instead of the full command.

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`.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 minutes | OpenSSH on Windows 10 / 11, macOS and Linux | A working SSH login |

## Before you start

* This file lives on **your computer**, not on the server.
* You need a working login first. See [how to SSH into a server](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md) and [SSH keys](https://help.freakhosting.com/portals/other/how-to-create-and-use-ssh-keys.md).
* PuTTY doesn't read this file. It uses [saved sessions](https://help.freakhosting.com/portals/other/how-to-use-putty-to-connect-to-your-server.md) instead.

## SSH config file example

```ini theme={null}
# ~/.ssh/config

Host web
    HostName 203.0.113.10
    User alex
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Host db
    HostName 10.0.0.5
    User alex
    ProxyJump web

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 3
    AddKeysToAgent yes
```

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

| Setting | Meaning |
| - | - |
| `Host web` | The short name you type. Everything indented below applies to it. |
| `HostName` | The real IP address or domain of the server. |
| `User` | The username to log in as. |
| `Port` | The SSH port. Default `22`. |
| `IdentityFile` | The private key to use. |
| `IdentitiesOnly yes` | Only try the key named in `IdentityFile`, not every key in your agent. Avoids `Too many authentication failures`. |
| `ProxyJump web` | Connect through another host (a "jump host" or bastion) first. |
| `ServerAliveInterval 60` | Send a keep-alive every 60 seconds so idle sessions aren't dropped. Default `0` (off). |
| `ServerAliveCountMax 3` | Disconnect after 3 unanswered keep-alives. Default `3`. |
| `AddKeysToAgent yes` | Add the key to the SSH agent after the first use, so you type the passphrase once. |

## How to create the SSH config file

> [tab] macOS / Linux
>
> ```bash theme={null}
> mkdir -p ~/.ssh
> chmod 700 ~/.ssh
> nano ~/.ssh/config
> ```
>
> Paste your `Host` blocks, save with **Ctrl+O**, exit with **Ctrl+X**, then lock the file down:
>
> ```bash theme={null}
> chmod 600 ~/.ssh/config
> ```

> [tab] Windows (PowerShell)
>
> ```powershell theme={null}
> New-Item -ItemType Directory -Force -Path $env:USERPROFILE\.ssh
> notepad $env:USERPROFILE\.ssh\config
> ```
>
> Paste your `Host` blocks and save. If Notepad adds `.txt`, choose **All files** in the save dialog so the file is called exactly `config`. Use forward slashes or `~` in paths, for example `IdentityFile ~/.ssh/id_ed25519`.

## Why order matters

For each setting, SSH uses the **first** value it finds ([ssh\_config manual](https://man.openbsd.org/ssh_config)). 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:

```bash theme={null}
ssh -G web | grep -E '^(hostname|user|port|identityfile) '
```

```text theme={null}
user alex
hostname 203.0.113.10
port 2222
identityfile ~/.ssh/id_ed25519
```

Then connect:

```bash theme={null}
ssh web
```

The alias also works for file transfers:

```bash theme={null}
scp backup.zip web:
rsync -avz ./site/ web:/var/www/site/
sftp web
```

## 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.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Create and use SSH keys](https://help.freakhosting.com/portals/other/how-to-create-and-use-ssh-keys.md)
>
> Make the key you point IdentityFile at.

> [card] [Change the SSH port](https://help.freakhosting.com/portals/other/how-to-change-the-ssh-port.md)
>
> Then save it as Port here.

> [card] [Copy files with scp and rsync](https://help.freakhosting.com/portals/other/how-to-copy-files-with-scp-and-rsync.md)
>
> Use your aliases for transfers.

> [card] [Keep sessions running](https://help.freakhosting.com/portals/other/how-to-keep-ssh-sessions-running-with-tmux-and-screen.md)
>
> tmux and screen.

***

> [!NOTE]
>
> **Checked against the official [OpenSSH ssh\_config manual](https://man.openbsd.org/ssh_config)** 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.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.