Image for post
Image for post

Another little fun tip that I created the other day. I have a cluster of machines, and I log into them as various users. I could type out the whole command to ssh into these various machines, but I’m lazy someone who likes to do things efficiently. Therefore, I wrote a little bash/zsh script to do this.

Here’s the bash:

The equivalent in zsh is:

This gives me aliases like this:

Now I can simply type one command to ssh to any of the hosts as either user, and I can also do tricks like this to do other commands involving whatever host I need:

The other advantage of doing it this way is that if I add hosts, they change IPs, whatever, I just update one associative array and everything else gets updated automatically. Simple!

Originally published on July 5, 2018.

Written by

I'm a technology enthusiast, always searching for better ways of doing things. Lately that has been all things React. I also write a lot on Medium. :)

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