Mosh supports .ssh/config
I've recently started using Mosh. It's a clever bit of software that keeps your SSH sessions running, even if your client goes offline or changes IP address.
But I find the syntax used to launch it a bit verbose and easy to forget. A typical command is something like:
mosh --ssh="ssh -p 1234" myname@example.com
Within the FAQ is a fleeting mention of how to configure Mosh. It says:
Q: How do I use a different SSH port (not 22)? As of Mosh 1.2, you can pass arguments to ssh like so:
mosh remotehost --ssh="ssh -p 2222"
Or configure a host alias in~/.ssh/config
with a Port directive. Mosh will respect that too.
What it doesn't say is that Mosh will use all the directives in ~/.ssh/config
. So you can have something like:
Host home
HostName example.com
User myname
Port 1234
Then you can run mosh home
to connect. If you don't want to use passwords, you can add IdentityFile ~/.ssh/example.key
or similar.
Perhaps you already knew that - but I didn't.
IAintShootinMis said on digitaldarkage.cc:
@Edent hey that makes Mosh a lot more useful!
Riley said on fosstodon.org:
@Edent thanks for sharing. I didn't even know Mosh was a thing. I frequently swap between hardwire and wifi at work, and I roam a decent amount. It always annoys me when connections hang. This sounds like the solution I have needed for awhile.
More comments on Mastodon.