Skip to content

Important bug fix for OpenSsh cme config editor

May 17, 2021

The new release of Config::Model::OpenSsh fixes a bugs that impacted experienced users: the order of Hosts or Match sections is now preserved when writing back ~/.ssh/config file.

Why does this matter ?

Well, the beginning of ssh_config man page mentions that “For each parameter, the first obtained value will be used.” and “Since the first obtained value for each parameter is used, more host-specific declarations should be given near the beginning of the file, and general defaults at the end.“.

Looks like I missed these statements when I designed the model for OpenSsh configuration: the Host section was written back in a neat, but wrong, alphabetical order.

This does not matter except when there an overlap between the specifications of the Host (or Match) sections like in the example below:

Port 22

Host *
Port 10022

With this example, ssh connection to “” is done using port 22 and connection to “” with port 10022.

If the Host sections are written back in reverse order:

Host *
Port 10022

Port 22

Then, ssh would be happy to use the first matching section for ““, i.e. “*” and would use the wrong port (10022)

This is now fixed with Config::Model::OpenSsh which is available on cpan and in Debian/experimental.

While I was at it, I’ve also updated Managing OpenSsh configuration with cme wiki page.

All the best

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: