Terence Eden. He has a beard and is smiling.
Theme Switcher:

Mosh supports .ssh/config

· 2 comments · 200 words · Viewed ~540 times


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…

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.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.