Skip to content

ssh-copy-id failing: Too many arguments #615

@basbebe

Description

@basbebe

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

I'm trying to run nixos-anywhere but I keep getting Too many arguments errors by ssh-copy-id which seem to have to do with the usage of the -i flag.

It works when I return to OpenSSH 9.6

I haven't figured out yet if this has to do with how nixos-anywhere uses ssh-copy-id or if it's a bug in ssh-copy-id.

Steps to Reproduce

ssh-copy-id -xn -i /tmp/test-nixos-anywhere ubuntu@10.10.10.210

If I omit the -i flag and its argument, ssh-copy-id works.

Debug Logs

[…]
+ sshUser=ubuntu
+ sshHost=10.10.10.210
+ [[ 1 != 1 ]]
+ uploadSshKey
+ local sshCopyHome=/home/basbebe
+ mkdir -p /home/basbebe/.ssh/
+ [[ -n '' ]]
+ ssh-keygen -t ed25519 -f /tmp/tmp.uBH8XwkMQb/nixos-anywhere -P '' -C nixos-anywhere
+ step Uploading install SSH keys
+ echo '### Uploading install SSH keys ###'
### Uploading install SSH keys ###
+ [[ n == y ]]
+ HOME=/home/basbebe
+ ssh-copy-id -o IdentitiesOnly=no -o ConnectTimeout=10 -o IdentitiesOnly=yes -i /tmp/tmp.uBH8XwkMQb/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o AddKeysToAgent=yes ubuntu@10.10.10.210
/run/current-system/sw/bin/ssh-copy-id: ERROR: Too many arguments.  Expecting a target hostname, got:

Usage: /run/current-system/sw/bin/ssh-copy-id [-h|-?|-f|-n|-s|-x] [-i [identity_file]] [-t target_path] [-F ssh_config] [[-o ssh_option] ...] [-p port] [user@]hostname
        -f: force mode -- copy keys without trying to check if they are already installed
        -n: dry run    -- no keys are actually copied
        -s: use sftp   -- use sftp instead of executing remote-commands. Can be useful if the remote only allows sftp
        -x: debug      -- enables -x in this shell, for debugging
        -h|-?: print this help
+ sleep 3
[…]

Command Used

nixos-anywhere --flake .#nix-host "ubuntu@10.10.10.210" --debug

Target System

Cloud server (AWS, DigitalOcean, etc.)

NixOS Version

25.11

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