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.


Share this post on…

  • Mastodon
  • Facebook
  • LinkedIn
  • BlueSky
  • Threads
  • Reddit
  • HackerNews
  • Lobsters
  • WhatsApp
  • Telegram

2 thoughts on “Mosh supports .ssh/config”

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="">