SSH Tips & Tricks: On killing & multiplexing Sessions, and checking Host Keys

Recently, I found out that none of my friends with own servers knew about these three ssh configuration options, so I decided to collect them and share them with everyone. :)

Kill a hung SSH Sessions without closing the Terminal

I used to close hung up ssh sessions by closing the full terminal or terminal tab, too, but a few years ago, I found out there’s a much better alternative. The ssh command line client actually has an escape sequence and then a few commands to control it! The magic key presses to close a session are: “⏎~.” (enter-tilde-dot). “⏎~” is the escape sequence, “.” is the command to terminate the session, and “⏎~?” shows all other available commands.

Check your SSH Fingerprints with ease using VisualHostKeys

One should compare one’s SSH host key fingerprints, but most of the time, one just assume it’s probably all right or checks the first and the last few characters, as comparing the fingerprint character by character is just too much work. Humans are much better at comparing visual patterns, though. Ever wondered what those „This is the key’s random art“ with a strange ASCII art image when you generate a key are all about? Only recently I found out that they are a visual representation of the fingerprint intended for easy comparison by humans.

# Show random art of the host key on every login
VisualHostKey yes

If you add this option globally to your .ssh/config, ssh will show you the SSH host key fingerprint as random art every time you log in to a server. This will train you to the pattern, and after a few weeks, you’d notice that the pattern is different immediately.

Multiplex SSH Sessions for more Performance

You can easily boost the performance of transfers of many small files by adding this as a global options to your .ssh/config. (Of course you could apply them to a few hosts only, too, but why should you?) This builds up only a single SSH connection to the target host and multiplexes all other ssh sessions to the same host over it. This also means that opening a second ssh session is almost instant.

# multiplex the connection when possible
Controlmaster auto
# location of the socket files
Controlpath ~/.ssh/ssh-%r@%h:%p.sock
# persist multiplex socket for 60 seconds when idle
Controlpersist 60

In case the full session hung up, you need to delete ~/.ssh/ssh-<username>@<hostname>:<port>.sock though, or wait 60 seconds for the idle timer to time out.

Remarks? Additions? Corrections? For anything you want to tell me about this blog post, feel free to send me an email[*].
Despite having no comments section (isn't that easy with a static site generator and without relying on a proprietary 3rd party service), I greatly appreciate direct feedback. 😉 In case of additions, I'll mention the name from the mail if you don't object.

[*]: Mails from small independent mailservers are my mailserver's favourite! ❤
If you don't want to keep one on your own, you can pay various admins about 1€ per month to do so for you, e.g. at posteo,, jit-creatives, or at most webhosting providers like netcup or 1&1 in case you want to have your own domain name on top.