Skip to content

presets/secure-node: turn off SSH password login for the sshd onion service - #273

Merged
prusnak merged 2 commits into
bitcoinix:masterfrom
ostermayer:secure-node-ssh-no-password
Nov 18, 2026
Merged

prusnak merged 2 commits into
bitcoinix:masterfrom
ostermayer:secure-node-ssh-no-password

Conversation

@ostermayer

@ostermayer ostermayer commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #132.

The secure-node.nix preset always publishes sshd as an onion service, but nothing in modules/ turned off SSH password login. Only the example configs did. NixOS allows passwords by default. So a config that imports the preset into an existing setup let anyone with the onion address try passwords over Tor. This includes the operator, who is in the groups that control funds (bitcoin, clightning, lnd).

The preset now sets services.openssh.settings.PasswordAuthentication and KbdInteractiveAuthentication to mkDefault false. sshd then accepts only keys, over the onion service and over the node's IP address. A config that needs passwords can still set either option to true.

This can lock out an account that logs in with a password, so it comes with a 0.2.0 notice. It fires for every config that uses the preset and enables sshd. A narrower condition would need to tell how the config defines the two options, and every way to do that missed some affected configs. A missed notice can lock the operator out of the node, and a needless one only costs a config version bump. The notice and the upgrade notes say that nothing changes for a config that already sets both options to false, like the flakes and Colmena examples.

Keyboard-interactive login through PAM depends on the PAM module, because NixOS sets security.pam.services.sshd.unixAuth from PasswordAuthentication. I checked sshd's PAM stack in the pinned nixpkgs:

  • googleAuthenticator: without unixAuth, the stack is only pam_deny, so such setups need both options set back to true. With services.homed.enable, NixOS adds the rule without unixAuth.
  • otpwAuth: with unixAuth, a sufficient pam_unix rule comes before pam_otpw, so a plain password would skip the one-time password. Such setups need only KbdInteractiveAuthentication = true.

The upgrade notes say this and tell users to test a new login before they close their session.

A config that sets one of the options to true with lib.mkDefault fails evaluation with "conflicting definition values", because the preset uses the same priority. This happens at any config version, before the notice shows. The upgrade notes say to set the option without lib.mkDefault.

Docs:

  • docs/upgrading.md: a 0.2.0 entry with the check, the PAM case, the conflict error and the way back.
  • docs/release-notes.md: a 0.2.0 entry.
  • docs/introduction.md and the SSH onion service section of docs/services.md now say that the preset turns off SSH password login.

Nothing else in the repo uses SSH password login. The tests, the QEMU and krops deployment scripts and the deployment examples all log in with keys. The preset doesn't change PermitRootLogin, so root keeps the NixOS default prohibit-password.

Testing

  • nix build .#checks.x86_64-linux.module-config passes. Two new tests:
    • testSecureNodeSshKeysOnly: the preset gives false for both options, an explicit true wins, and without the preset both stay true. It fails with the preset from master.
    • testVersioningSecureNodeSshPasswords: the notice fires with the preset and sshd, not with sshd disabled, not without the preset, and not for a 0.2.0 config once 0.2.0 is released.
  • nix build .#checks.x86_64-linux.test-runner passes.
  • nix eval .#ciTestInfo passes.
  • ./test/run-tests.sh -s secureNode passes.
  • A config with the preset and PasswordAuthentication = lib.mkDefault true fails with "conflicting definition values" before and after 0.2.0 is released.
  • After the rebase onto master c3d955c (Keep unreleased migration notices visible on master #283), module-config, test-runner, ci-workflows and secureNode pass on the KVM host. acknowledged replaces current, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass with version.nix at 0.1.6 and at 0.2.0.

Models

Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed the second rebase.

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service status: rebase needed Merge conflicts need to be resolved labels Nov 16, 2026
@ostermayer
ostermayer force-pushed the secure-node-ssh-no-password branch from 11dabea to 7943b31 Compare November 16, 2026 14:38
@github-actions github-actions Bot removed the status: rebase needed Merge conflicts need to be resolved label Nov 16, 2026

@viberaven viberaven left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 7943b31b3ccb.

No actionable findings. Checked both SSH authentication defaults, explicit overrides, preset detection, and the migration notice against the account-lockout risk. The upgrade instructions cover password login, keyboard-interactive/PAM configurations, and equal-priority mkDefault conflicts. Local module-config and mdBook builds pass. CI is green; I did not rerun the SSH VM scenario locally.

Review performed with Codex (GPT-6 Astra).

@github-actions github-actions Bot added the status: rebase needed Merge conflicts need to be resolved label Nov 16, 2026
@seberm

seberm commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

LGTM, just please focus v0.2.0.


Changes requested: only to fit the notice contract on master (#283). The preset change and tests look good.

Must fix (rebase onto master):

  • Move modules/versioning/0.1.7/secure-node-ssh-password-login.nix to modules/versioning/0.2.0/.
  • Drop the examples/configuration.nix bump. Examples stay at the released version (0.1.6) until release prep.
  • docs/release-notes.md: move the entry into the existing ## 0.2.0 section.
  • docs/upgrading.md: move the entry into the existing ## Upgrading to config version 0.2.0 section and drop its own set nix-bitcoin.configVersion = "0.1.7" line. That section already ends with the deferred-version wording.
  • testVersioningSecureNodeSshPasswords: passesVersionCheckAt "0.1.7" now fails, because config versions newer than version.nix are rejected. Use releasedVersion and expect changes020Released, as the other 0.2.0 notice tests do.

Should fix:

  • Update the 0.1.7 references in the PR description to 0.2.0.

Assisted-by: Claude Code (Claude Opus 5.5)

@seberm seberm added this to the v0.2.0 milestone Nov 17, 2026
@ostermayer
ostermayer force-pushed the secure-node-ssh-no-password branch from 7943b31 to cdd7cc9 Compare November 18, 2026 00:19
…ervice

The secure-node preset always publishes sshd as an onion service, but
nothing in the modules turned off SSH password login. Only the example
configs did. NixOS allows passwords by default, so a config that imports
the preset into an existing setup let anyone with the onion address try
passwords over Tor. This includes the operator, who is in the groups that
control funds.

The preset now sets PasswordAuthentication and
KbdInteractiveAuthentication to false with mkDefault, so sshd accepts
only keys and a config can still turn them back on. This can lock out
an account that logs in with a password or with one-time codes through
PAM, so a 0.2.0 notice reports it to every config with the preset and
sshd.

Fixes bitcoinix#132.

Assisted-by: Claude Code (Claude Opus 5.5)
@ostermayer
ostermayer force-pushed the secure-node-ssh-no-password branch from cdd7cc9 to db3e418 Compare November 18, 2026 01:01
@github-actions github-actions Bot added status: rebase needed Merge conflicts need to be resolved and removed status: rebase needed Merge conflicts need to be resolved labels Nov 18, 2026
@prusnak
prusnak enabled auto-merge November 18, 2026 10:31
@github-actions github-actions Bot removed the status: rebase needed Merge conflicts need to be resolved label Nov 18, 2026
@prusnak
prusnak merged commit 9fc8516 into bitcoinix:master Nov 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

presets/secure-node: the sshd onion service is published while NixOS still allows password authentication

4 participants