You Don’t Need to Type a Lengthy SSH Command

Image for post
Image for post
  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 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 code that spawns VMs to provide this configuration as .

Originally published at .

Open Source | DevOps | Infrastructure | Backend | Ployglot Programmer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store