Skip to content

Cannot set SSH UserKnownHostsFile using --ssh-option #552

@stefankreutz

Description

@stefankreutz

Prerequisites

  • I have updated to the latest version using nix run --refresh github:nix-community/nixos-anywhere
  • I have reproduced the issue with the --debug flag
  • I have searched existing issues to make sure this isn't a duplicate

Bug Description

When supplying --ssh-option "UserKnownHostsFile=foo" to nixos-anywhere as described in the CLI usage help, it still uses /dev/null.

I think this is because the value of the --ssh-option gets appended to the default SSH arguments.

OpenSSH uses the first UserKnownHostsFile setting on the command-line, and ignores the second. Thus, one cannot override the default UserKnownHostsFile=/dev/null.

The same applies to the other default arguments, notably StrictHostKeyChecking=no.

I think this could be fixed by prepending the --ssh-option values to the default SSH arguments.

Steps to Reproduce

  1. Run nixos-anywhere --ssh-option "UserKnownHostsFile=$HOME/foo" ....
  2. Confirm "$HOME/foo" is empty.

Debug Logs

N/A

Command Used

nixos-anywhere --ssh-option "UserKnownHostsFile=$HOME/foo" ...

Target System

Virtual machine

NixOS Version

unstable

Environment Information

  • Host OS:
  • Nix version:
  • Target architecture:

Configuration Files

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions