Linux SSH Session Management for Network Engineers

A few weeks ago I bought myself a new Dell XPS-13 and decided for the n-th time to go all-in Linux, that is to have Linux as the main and only laptop OS. Since most of my Linux experience is with Fedora-family distros, I quickly installed Fedora-25 and embarked on a long and painful journey of getting out of my Windows comfort zone and re-establishing it in Linux. One of the most important aspects for me, as a network engineer, is to have a streamlined process of accessing network devices. In Windows I was using MTPutty and it helped define my expectations of an ideal SSH session manager:

I want a multi-tab terminal with the ability to switch between tabs quickly - default (GNOME) terminal does that out-of-the box with no extra modifications

I want to login the device without having to enter a password - Not available by default but is possible with some dirty expect hacks.

I want my SSH sessions to be organised in a hierarchical manner with groups representing various administrative domains - customer A, local VMs, lab.

Although GNOME terminal looked like a very good option, it didn’t meet all of my requirements. I briefly looked and PAC Manager and GNOME Connection Manager but quickly dismissed them due to their ugliness and clunkiness. Ideally I wanted to keep using GNOME terminal as the main terminal emulator, without having to configure and rely on other 3rd party apps. I also didn’t want to wrap my SSH session in expect as I didn’t want my password to be pasted in my screen every time I cat a file containing the trigger keyword Password:. I’ve finally managed to make everything work inside the native GNOME terminal and this post is a documentation of my approach.

3. Define zsh aliases

The final step is session organisations. For that I’ve decided to use zsh aliases and have device groups encoded in the alias name, separated by dashes. For example, if my SRX device was in the lab and Arista was in Site-51 of Customer-A this is how I would write my aliases:

alias lab-srx='ssh srx'
alias customer-a-site-51-arista='ssh arista'

4. Multi-pane sessions with tmux

As a network engineer, I often find myself troubleshooting issues spanning multiple devices, which is why I need multiple tabs inside a single terminal window. Simply pressing Ctrl+T in GNOME terminal opens a new tab and I can switch between tabs using Alt+[1-9]. However what would be really nice is to have a couple of tabs opened side by side so that I can see the logs and compare output on a number of devices at the same time. This is where tmux comes in. It can do much more than this, but I simply use it to have multiple panes inside the same terminal tab: