Mosh ssh alternative & tmux terminal multiplexer

I am one of the old school *nix users who still feel more comfortable with cli when doing upgrades, debugging etc.
Neon has ssh access but every night when I suspend my desktop, the connection drops and I have to re-login when I resume my desktop.

I have switched to using mosh instead:

There doesn’t seem to be a native windows client, so if you use windows on your desktop this might not be for you.
Installing is as easy as this once you have logged in with ssh to your neon:

sudo apt install mosh

From my (linux) desktop I simply type

mosh neon@neon

When I now suspend/resume my desktop, the connection with NEON will still be there.

Next on my list was wanting to use multiple screens over that mosh/ssh connection.
I had used program called “screen” in the past but i heard good things about tmux

The standard control key is control-b which i changed to control-a instead

The command to change that to control-a and add some fancy coloring is this:

#as user neon
cat <<EOF > ~/.tmux.conf

# Rebind to Ctrl-a
set -g prefix C-a
unbind C-b
bind a send-prefix
bind C-a last-window
bind '"' choose-window

# Rebind pane splitting
unbind %
bind - split-window -v
bind _ split-window -h

# Set status bar
set -g status-bg colour236
set -g status-fg white
set -g status-left '#[fg=green]#H'

# Highlight active window
setw -g window-status-style fg=cyan,bg=colour164,dim
setw -g window-status-current-style fg=white,bg=red,bright

# Force 256 colors
set -g default-terminal "screen-256color"

install the program itself:

sudo apt install tmux

Once you are logged in with either ssh or mosh you type tmux
You will get a prompt like normal but you will have an extra line on the bottom.
With my changed key setup you now hit control-a c (from create) and you now see 2 sessions at the bottom line.
You can switch between the 2 screens with control-a a or if you have multiple screens control-a [number] eg 3 for the third screen.
control-a d will detach you tmux, but it will be still running
next time you login and want to pickup where you left, use

tmux attach

if you are loggin in from a different machine and you want to take over an existing tmux session you use

tmux attach -d

-d == detach old session

I normally have one session with neon-cli running, a screen where i am ‘neon’ and a screen where i am root.

1 Like