Skip to content

chezmoi init commands do not use ssh config file when cloning #5036

@BaccanoMob

Description

@BaccanoMob

Describe the bug

I try to run,

chezmoi docker exec dev-container ssh://git@selfhosted.git/me/dotfiles.git
# or
chezmoi init  ssh://git@selfhosted.git/me/dotfiles.git

I am prompted to enter password. And then it fails by connection closed by IPADDR port 22.

But by ssh config

Host selfhosted.git
  Port 222
  IdentityFile "/config/.ssh/id"

I assume it will be the same for ssh command as well

To reproduce

To replicate in any device,

  1. Change your SSH port to something else in the device you want to init.
  2. Attempt chezmoi ssh ... command from your machine (provided you change your ssh config to below, identity file is optional to reproduce this problem)
Host REMOTE_IP
  Port <CHANGED_PORT>

Expected behavior

Chezmoi initializes the dotfiles

Output of command with the --verbose flag

None

Output of chezmoi doctor

Details
RESULT    CHECK                       MESSAGE
ok        version                     v2.70.2, commit b1aacd726df533ffd1f2fec7ded8e2ecfdb26e0e, built at 2026-04-17T00:17:32Z, built by goreleaser
ok        latest-version              v2.70.2
ok        os-arch                     linux/amd64 (Ubuntu 24.04.3 LTS (Noble Numbat))
ok        build-info                  -ldflags=-s -w -X main.version=2.70.2 -X main.commit=b1aacd726df533ffd1f2fec7ded8e2ecfdb26e0e -X main.date=2026-04-17T00:17:32Z -X main.builtBy=goreleaser, CGO_ENABLED=1, GOAMD64=v1
ok        uname                       Linux 3e01b1fb7897 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
ok        go-version                  go1.26.2 (gc)
ok        executable                  ~/.local/bin/chezmoi
ok        upgrade-method              replace-executable
info      config-file                 ~/.config/chezmoi/chezmoi.toml: not found
ok        source-dir                  ~/.local/share/chezmoi is a directory
ok        suspicious-entries          no suspicious entries
ok        working-tree                ~/.local/share/chezmoi is a directory
ok        dest-dir                    ~ is a directory
error     hardlink                    failed creating hardlink from ~/.local/share/chezmoi to /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor3725434305/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok        symlink                     created symlink from .new-name to .old-name
ok        umask                       022
ok        cd-command                  found /bin/bash
ok        cd-args                     /bin/bash
info      diff-command                not set
warning   edit-command                vi not found in $PATH
ok        edit-args                   vi
ok        git-command                 found /usr/bin/git, version 2.43.0
warning   merge-command               vimdiff not found in $PATH
ok        shell-command               found /bin/bash
ok        shell-args                  /bin/bash
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.4.4
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler not found in $PATH
info      gopass-command              gopass not found in $PATH
info      keepassxc-command           keepassxc-cli not found in $PATH
info      keepassxc-db                not set
info      keeper-command              keeper not found in $PATH
info      lastpass-command            lpass not found in $PATH
info      pass-command                pass not found in $PATH
info      passhole-command            ph not found in $PATH
info      protonpass-command          pass-cli not found in $PATH
info      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      secret-command              not set

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportSupport request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions