---
title: "SSH config file: reach several servers with a short name | StreetHosting"
description: "Set up ~/.ssh/config with Host, HostName, User, IdentityFile and ProxyJump to connect to several servers with a short name, on both Linux and Windows."
url: "https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers"
type: "page"
language: "en-US"
---

VPS · 8 min · Beginner

Published on Nov 13, 2026 · Updated on Nov 13, 2026

# How to use the SSH config file to reach several servers with aliases

Stop memorizing IPs, ports and key paths. With one block per server in the SSH config file you connect with ssh prod, and the same alias works in scp, rsync and VS Code.

By [Equipe StreetHosting](https://streethosting.com.br/en/autores#equipe-streethosting) · StreetHosting infrastructure and support team

[Linux administration](https://streethosting.com.br/en/guides/topics/linux) [Windows and RDP](https://streethosting.com.br/en/guides/topics/windows)

Summarize with:

[](https://chat.openai.com/?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "ChatGPT") [](https://claude.ai/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Claude") [](https://www.google.com/search?udm=50&aep=11&q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Google AI Mode") [](https://x.com/i/grok?text=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Grok") [](https://www.perplexity.ai/search/new?q=Summarize%20the%20key%20points%20of%20this%20StreetHosting%20guide%3A%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers.%20Highlight%20the%20step-by-step%20instructions%2C%20the%20prerequisites%20and%20the%20most%20common%20mistakes. "Perplexity")

Share:

[](https://x.com/intent/tweet?text=SSH%20config%20file%3A%20reach%20several%20servers%20with%20a%20short%20name&url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers "Share on X") [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers "Share on Facebook") [](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers "Share on LinkedIn") [](https://wa.me/?text=SSH%20config%20file%3A%20reach%20several%20servers%20with%20a%20short%20name%20https%3A%2F%2Fstreethosting.com.br%2Fen%2Fguides%2Fvps%2Fssh-config-multiple-servers "Share on WhatsApp")

For agents: Copy as Markdown [.md](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers.md)

In this guide 8 sections

* [What the SSH config is for](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#o-que-e)
* [Your first Host block](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#bloco)
* [Several servers and keys](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#varios)
* [A server behind another](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#proxyjump)
* [Settings for everyone](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#curinga)
* [scp, rsync and VS Code](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#ganhos)
* [Permissions and problems](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#permissoes)
* [Where to run it](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#onde-rodar)

Quick answer

The `~/.ssh/config` file (on Windows, `C:\Users\yourname\.ssh\config`) holds one `Host` block per server, with `HostName`, `User`, `Port` and `IdentityFile`. Then you connect with just `ssh prod`, instead of typing user, IP, port and key. The same alias works in `scp`, in `rsync` and in VS Code.

## What the SSH config is for[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#o-que-e)

Anyone with a VPS ends up typing something like this every day: `ssh -i ~/.ssh/id_ed25519_vps -p 2222 deploy@203.0.113.10`. With two or three servers, each with a different user, port and key, the command becomes a source of mistakes and of cheat sheets in a text editor.

The SSH client reads a configuration file on every connection. In it you describe each server once and give it a short alias. From then on, the command is `ssh prod`. This file lives on your computer, the client, and not on the server. It changes nothing on the VPS and does not affect anyone else who connects to it.

This guide assumes you already have an SSH key. If you do not, see [how to set up an SSH key on Windows](https://streethosting.com.br/en/guides/vps/set-up-ssh-key-windows) or the guide on [passwordless SSH key login on your VPS](https://streethosting.com.br/en/guides/vps/passwordless-ssh-login-vps).

## Your first Host block[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#bloco)

The file lives in different places depending on the system:

| System          | File path                         |
| --------------- | --------------------------------- |
| Linux and macOS | \~/.ssh/config                    |
| Windows         | C:\\Users\\yourname\\.ssh\\config |

If the file does not exist, create it. On Linux and macOS: `mkdir -p ~/.ssh && nano ~/.ssh/config`. On Windows, open PowerShell and run the three lines below. They create the folder and the empty file, named exactly **config** with no .txt at the end, and open it in Notepad. If the file already exists, the second line only shows a warning and deletes nothing.

`New-Item -ItemType Directory -Force $env:USERPROFILE\.ssh New-Item -ItemType File $env:USERPROFILE\.ssh\config notepad $env:USERPROFILE\.ssh\config`

A block for one server:

`Host prod HostName 203.0.113.10 User deploy Port 22 IdentityFile ~/.ssh/id_ed25519 IdentitiesOnly yes ServerAliveInterval 60`

* **Host:** the alias you type. It can be any word without spaces: prod, store, bot.
* **HostName:** the real address, an IP or a domain.
* **User:** the login user, so you do not have to write user@ before the address.
* **Port:** the SSH port. It is only needed when it is not 22, but writing it down helps you remember.
* **IdentityFile:** the path of the private key, the one without the .pub extension.
* **IdentitiesOnly yes:** SSH uses only this key. Without it, SSH may try every key in the agent, and the server cuts the connection after a few attempts with the error `Too many authentication failures`.
* **ServerAliveInterval 60:** every 60 seconds the client sends a signal to the server. This keeps routers and firewalls from dropping an idle session.

Save it and test with `ssh prod`. If something looks odd, the command `ssh -G prod` shows every option SSH is going to apply, without connecting.

On Windows, prefer writing key paths with forward slashes, such as `C:/Users/yourname/.ssh/id_ed25519`, or in the tilde format, such as `~/.ssh/id_ed25519`, which Windows OpenSSH also understands.

## Several servers and keys[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#varios)

Each server gets its own block. Separate the keys by project or by client: if one leaks, only one environment is exposed.

`Host prod HostName 203.0.113.10 User deploy IdentityFile ~/.ssh/id_ed25519_prod IdentitiesOnly yes Host staging HostName 203.0.113.20 User deploy Port 2222 IdentityFile ~/.ssh/id_ed25519_staging IdentitiesOnly yes Host bot HostName bot.exemplo.com.br User root IdentityFile ~/.ssh/id_ed25519_bot IdentitiesOnly yes`

Now `ssh staging` gets in on port 2222 with the right key, without you remembering any of it. To see which aliases exist, run `grep "^Host " ~/.ssh/config` on Linux or macOS. Using a port other than 22 is one of the measures described in [securing SSH on your VPS](https://streethosting.com.br/en/guides/vps/secure-ssh-linux-vps), and the config file is exactly what makes that measure comfortable to live with.

## A server behind another[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#proxyjump)

On some networks only one server accepts SSH from the internet, the so-called bastion, and the others answer only to it. To reach the internal server you would have to connect to the first and, from there, to the second. ProxyJump makes that hop for you:

`Host bastion HostName 203.0.113.10 User deploy IdentityFile ~/.ssh/id_ed25519_prod IdentitiesOnly yes Host interno HostName 10.0.0.15 User deploy ProxyJump bastion IdentityFile ~/.ssh/id_ed25519_prod IdentitiesOnly yes`

When you run `ssh interno`, your SSH opens the connection to the bastion and, inside it, opens the connection to the internal server. Nothing is stored on the bastion: your private key stays only on your computer, and the bastion just relays the traffic. The HostName of the internal server is the address the _bastion_ sees, so it can be a private network IP. For a one-off hop, without touching the file, use `ssh -J deploy@203.0.113.10 deploy@10.0.0.15`.

Avoid using ForwardAgent to reach the internal server. It makes your key agent reachable on the bastion, and anyone who is root there can use your keys while you are connected. ProxyJump solves the same problem without that risk.

## Settings for everyone[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#curinga)

The `Host *` block applies to any server and is for what all of them share. It goes at the **end** of the file, because SSH uses the first value it finds for each option, reading from top to bottom. If the wildcard came first, it would win over the specific blocks.

`Host * ServerAliveInterval 60 ServerAliveCountMax 3 AddKeysToAgent yes IdentitiesOnly yes`

* **ServerAliveCountMax 3:** after 3 signals with no answer, the client ends the session instead of staying frozen. With the 60-second interval, that is about 3 minutes.
* **AddKeysToAgent yes:** the first time you use a key with a passphrase, it is kept in the key agent, if one is running, and the passphrase is not asked again while the agent stays up.

You can also use patterns in the name, such as `Host web1 web2 web3` or `Host *.exemplo.com.br`, to repeat the same user and key across a fleet of machines.

## scp, rsync and VS Code[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#ganhos)

The alias is not only for the ssh command. Every program that uses the system's SSH client reads the same file:

`# send a file scp site.zip prod:/home/deploy/ # download a folder scp -r prod:/home/deploy/logs ./logs # sync a folder, only what changed rsync -avz ./dist/ prod:/var/www/site/ # run a command without opening a session ssh prod "systemctl status app"`

No user, port or key on the line: it all comes from the block. The guide on [transferring files with scp and rsync](https://streethosting.com.br/en/guides/vps/transfer-files-to-vps-scp-rsync) details the options of each. VS Code with the Remote - SSH extension also lists every alias in the file when you connect, as you can see in the guide on [VS Code Remote SSH on your VPS](https://streethosting.com.br/en/guides/vps/vs-code-remote-ssh-vps). The same goes for Git and other tools that call the system's ssh.

## Permissions and problems[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#permissoes)

SSH is strict about permissions because the file and the keys define who you are. On Linux and macOS, set them like this:

`chmod 700 ~/.ssh chmod 600 ~/.ssh/config chmod 600 ~/.ssh/id_ed25519*`

The problems that show up most often:

1. **Bad owner or permissions on**, followed by the config path: on Linux, run the commands above. On Windows, the file has to belong to your user, and other users cannot have write permission on it. Adjust it in the file properties, on the Security tab.
2. **The alias seems ignored:** check that the file did not end up as config.txt and run `ssh -G alias` to see what SSH actually applies.
3. **Permission denied (publickey):** the IdentityFile path is wrong, the public key is not on the server or the User is different. Run `ssh -v alias` and read which keys were offered.
4. **An option is ignored because it is in the wrong block:** remember that the first value found wins. Specific blocks come before `Host *`.

Back up the file from time to time. It holds the map of all your servers, and rebuilding it from memory is tedious. It has no passwords, only paths, so it is safe to version in a private repository, as long as the private keys stay out.

## Where to run it[](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#onde-rodar)

On [StreetHosting VPS](https://streethosting.com.br/en/vps) you reach the machine over SSH with the root user or with the user you create, straight on its dedicated IP. Each VPS becomes a block in your file, and the day-to-day work with several machines is one alias away. The first access is covered in [how to access your VPS for the first time](https://streethosting.com.br/en/guides/vps/connect-to-vps-via-ssh-first-time).

The Xeon VPS starts at R$ 26.00 per month, with 2 vCPU, 2 GB of RAM and 20 GB of NVMe. All of them are in São Paulo, with AntiDDoS included, up to 5 TB of traffic per month and activation in about 60 seconds after Pix or card approval.

In this guide

* [What the SSH config is for](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#o-que-e)
* [Your first Host block](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#bloco)
* [Several servers and keys](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#varios)
* [A server behind another](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#proxyjump)
* [Settings for everyone](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#curinga)
* [scp, rsync and VS Code](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#ganhos)
* [Permissions and problems](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#permissoes)
* [Where to run it](https://streethosting.com.br/en/guides/vps/ssh-config-multiple-servers#onde-rodar)

## Frequently asked questions

Where is the SSH config file on Windows?

At C:\\Users\\yourname\\.ssh\\config, with no extension. If you create it in Notepad, check that it did not save as config.txt, because in that case SSH ignores the file.

Does the file need special permissions?

On Linux and macOS, use chmod 600 \~/.ssh/config and chmod 700 \~/.ssh. SSH refuses the file if other users can write to it. On Windows, the file must belong to your user, and other users cannot have write permission on it.

What is IdentitiesOnly for?

It makes SSH offer only the key named in IdentityFile, not every key in the agent. Without it, someone with many keys can hit the Too many authentication failures error before reaching the right one.

Does ProxyJump require installing anything on the middle server?

No. The middle server only has to accept your SSH connection, allow TCP forwarding, which is on by default in OpenSSH, and be able to reach the destination. Your computer opens a tunnel through it, and the private keys stay only with you.

How do I see which configuration SSH is applying?

Run ssh -G alias. It prints every option that applies to that host after merging the blocks, without connecting. To see the connection in detail, use ssh -v alias.

Next step

See VPS plans

Root VPS in Brazil with NVMe and Anti-DDoS.

[See VPS plans](https://streethosting.com.br/en/vps)

## Related guides

[VPS Beginner Set up an SSH key on Windows to access your VPS Windows already ships the OpenSSH client, so you can generate and use keys without installing anything. Here is the step by step in PowerShell, the most common permission errors and the path for anyone who prefers PuTTY. 9 min Read guide](https://streethosting.com.br/en/guides/vps/set-up-ssh-key-windows) [VPS Intermediate How to set up passwordless SSH key login on a VPS Key-based login is safer and easier than a password. You generate a key pair, copy the public key to the server, and log in without typing anything. Here is how, in a few steps. 3 min Read guide](https://streethosting.com.br/en/guides/vps/passwordless-ssh-login-vps) [VPS Beginner VS Code Remote SSH: edit and run code directly on your VPS With the Remote SSH extension, VS Code opens the folder that lives on your VPS as if it were local, with the terminal, extensions and debugger running there. See the setup, the memory use and what to do when it hangs. 9 min Read guide](https://streethosting.com.br/en/guides/vps/vs-code-remote-ssh-vps)

[← Back to the Guide Center](https://streethosting.com.br/en/guides)
