You Don’t Need to Type a Lengthy SSH Command

  1. With ssh we often deal with lengthy domain names and plain IP addresses. To ssh easily we usually create short aliases by adding entries to /etc/hosts. This can be done using ~/.sshconfig itself:
Host my-server-1

Host my-server-2


To access

ssh user@my-server-1

To access

ssh user@my-server-2

2. In SSH via Jump Server in One Step I shared about ssh-ing via jump servers in one step using the -J option. This too can be configured in ~/.sshconfig.

To access that is accessible only through we would do:

ssh -J user@ user@

With the following in ~/.sshconfig:


We could just do:

ssh user@

3. Similarly, many other configs like username, key filename could be pushed to ~/.sshconfig:

Host my-server
User foo
IdentityFile ~/foo.pem

Host my-jump-server
User bar
IdentityFile ~/bar.pem

Now just by doing ssh my-server we will have access to

Pushing these configurations to ~/.sshconfig will be very helpful if you ssh into many machines often. We could also share this with other members of the team easily.

We could also auto-generate the configuration as part of our infrastructure automation. For example, we could make a terraform code that spawns VMs to provide this configuration as output .

Originally published at

Open Source | DevOps | Infrastructure | Backend | Ployglot Programmer