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"

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
     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.

Share this post on…

2 thoughts on “Mosh supports .ssh/config”

  1. says:

    @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.


What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">