Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden ssh config defaults and remove old host key support #31763

Merged
merged 3 commits into from Nov 20, 2017
Merged

Harden ssh config defaults and remove old host key support #31763

merged 3 commits into from Nov 20, 2017

Conversation

jeaye
Copy link
Contributor

@jeaye jeaye commented Nov 17, 2017

Motivation for this change

To better harden the SSH service by default. This was originally mentioned by @jpierre03 here: #20161 (comment) -- I'm just looking to get the ball rolling.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.
Things to note

This breaks backward compatibility with anyone using supportOldHostKeys. If people want that, I think extraConfig will do the trick.


@jeaye jeaye changed the title RFC: Harden ssh config defaults and remove old host key support Harden ssh config defaults and remove old host key support Nov 17, 2017
@@ -363,14 +358,21 @@ in
HostKey ${k.path}
'')}

# Allow DSA client keys for now. (These were deprecated
# in OpenSSH 7.0.)
PubkeyAcceptedKeyTypes +ssh-dss
Copy link
Member

@Mic92 Mic92 Nov 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be mentioned in the release notes. Otherwise people might get locked out.

UPDATE maybe this was already removed in openssh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is important to mention in the release notes. I don't think it's been fully removed yet, just deprecated.

OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option:

https://www.openssh.com/legacy.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be found here: nixos/doc/manual/release-notes/rl-1803.xml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/nixos/doc/manual/release-notes/rl-1803.xml b/nixos/doc/manual/release-notes/rl-1803.xml
index c1fe692cee..8bc9cd9133 100644
--- a/nixos/doc/manual/release-notes/rl-1803.xml
+++ b/nixos/doc/manual/release-notes/rl-1803.xml
@@ -72,6 +72,16 @@ following incompatible changes:</para>
       <option>services.pgmanage</option>.
     </para>
   </listitem>
+  <listitem>
+    <para>
+      The OpenSSH service no longer enables support for DSA keys by default,
+      which could cause a system lock out. DSA support was
+      <link xlink:href="https://www.openssh.com/legacy.html">deprecated in OpenSSH 7.0</link>,
+      due to it being too weak. To re-enable support, add
+      <literal>PubkeyAcceptedKeyTypes +ssh-dss</literal> to the end of your
+      <option>services.openssh.extraConfig</option>.
+    </para>
+  </listitem>
 </itemizedlist>
 
 </section>

Look reasonable?

@NeQuissimus NeQuissimus added this to the 18.03 milestone Nov 17, 2017
@@ -54,8 +54,6 @@ let
));
in listToAttrs (map mkAuthKeyFile usersWithKeys);

supportOldHostKeys = !versionAtLeast config.system.stateVersion "15.07";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the release notes, after fixing their host keys, they can safely change their state version from anything prior to 17.03, to 17.03, as vetted here: https://search.nix.gsc.io/?q=stateVersion

Since ssh-dss is no longer supported by default, users relying on those
keys for their login may be locked out. They should ideally use stronger
keys, but adding the support for ssh-dss back in can also be done
through extraConfig.
@jeaye
Copy link
Contributor Author

jeaye commented Nov 20, 2017

Anything more needed on this?

@NeQuissimus NeQuissimus merged commit 861fef7 into NixOS:master Nov 20, 2017
@NeQuissimus
Copy link
Member

Thank you for this, LGTM

@jpierre03
Copy link
Contributor

@jeaye thanks.
A similar ssh client configuration can be acheived #20161 (comment) and overriden if necessary with $HOME/.ssh/config directives.

@jeaye
Copy link
Contributor Author

jeaye commented Jan 5, 2018

@jpierre03 Yes indeed. I'd like very much to see more things like this become (available) defaults in NixOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants