Tip: Alias SSH Connections

Use an alias for SSH connections

In Short

alias ball="ssh alexa@123.123.123.123" in .bashrc

Details

Connecting via SSH requires a command that looks like ssh user@ip.v4.host.machine, so if you find yourself connecting via SSH to a remote computer often, potentially even several computers, you likely find yourself having to memorize IP addresses to instantiate connections.

To put a handle on the verbose commands, add an alias command locally. There are a few different places this command can be defined. For Ubuntu, I’ll put it in the .bashrc file. If you are unsure of where to define this alias for your OS, do a quick web search for “add command alias [your system]”.

Given a remote user of alexa at a remote host with IP address 123.123.123.123, I will add the following to the .bashrc file:

alias ball="ssh alexa@123.123.123.123"

I will need to reload the shell, then afterward if I issue the command ball , the aliased command will be run, and an SSH connection will be initiated.

On MacOS, as you likely know, the standard run command file is .zshrc , not .bashrc.

For setting an alias on Windows, see the dedicated article Alias Commands on Windows.

And folks using non-standard configuration, this should get you going in the right direction.

alexa anderson

About the Author

Alexa Anderson is an engineer and evangelist with a penchant for making products geared for progress and achievement. When not writing software, Alexa spends her time curating content and sharing her discoveries.