How to run tmux via ssh instantly

With my Raspberry Pi, what I do very, very often is this:

localhost$ ssh raspberrypi.local    # Here I already type the next command and wait a while
raspberrypi$ tmux attach

This is all well and good, but sometimes the Pi is down, and I will attach to one of my local tmux sessions. Very annoying. Instead you could try to do this:

localhost$ ssh raspberrypi.local tmux attach
not a terminal

Well, that did no good. So a look at the man-page of ssh or a quick search reveals this gem:

localhost$ ssh raspberrypi.local -t tmux attach

This allocates a pseudo terminal, which is needed by tmux to function correctly. This is also done by ssh, if no command is given, but a login shell is spawned.

Printing the SSH host key fingerprint

Whenever you update your SSH host keys, your machine becomes compromised, or you re-install your system, the SSH host key will change. To check if there is really a man in the middle attack, it is nice to be able to print out the fingerprint of the SSH host key on the host itself. So locally log onto your machine, and do the following:

$ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub

If you are using the DSA key, you should replace rsa with dsa, naturally.