Skip to main content
Sheelah Brennan

Productivity Tip #1: Use SSH Aliases for Frequently Visited Hosts

I’m starting a new series of posts with some web development productivity tips. Let’s get started!

If you frequently SSH or SCP to the same host machines, save yourself some typing and create aliases for those hosts to speed up the process. It’s well worth the few minutes to set this up on your Mac or linux system.

  1. Create a ~/.ssh/config file. If you don’t have a .ssh directory in your home directory, create that first using mkdir ~/.ssh.
  2. Open the ~/.ssh/config file using the code editor of your choice and add an entry like the one below for each host you want to use with an alias:
Host mywebsite
User jodie
Port 22
Hostname qz33xdk3.webhost.net

In this example, the alias name for this host is mywebsite, and you’ll connect to port 22 of that host. To ssh to the website, you’ll just run ssh mywebsite instead of needing to type the full hostname. Easy peasy :).

  1. If you connect to the host using a private key that you’ve set up, you can specify the key in your ~/.ssh/config as well. The normal path for your keys is also in the ~/.ssh directory.
IdentityFile ~/.ssh/mywebsite
IdentitiesOnly yes
  1. Test your config by attempting to connect to the aliased host. For example: ssh mywebsite.
  2. Add other hosts to your ssh config file as needed. A sample file with multiple hosts would look something like this:
Host mywebsite
User jodie
Port 22
Hostname qz33xdk3.webhost.net

Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/git