Skip to content

.ssh directory is copied in the wrong home #42

Description

@Griffures

Proper bug report of #12 (comment)


Describe the bug

/config/.ssh/ on host HA gets copied to /tmp/.ssh/ in the container instead of /root/.ssh/.
This causes public keys and configurations to fail for custom git forge.


To Reproduce

Steps to reproduce the behavior:

  1. Be sure to have a proper SSH key setup in your gitforge (In my example Gitlab)
  2. Set custom remote url in Settings to your ssh remote (i.e. git@gitlab.com:Griffures/my_repo_name.git)
  3. Use either the terminal or the file explorer addon to create/transfer your ssh keys in /config/.ssh, as well as the config file.
~ ls -la /config/.ssh
total 20
drwxr-xr-x    2 root     root          4096 Jul 17 18:28 .
drwxr-xr-x   14 root     root          4096 Jul 17 17:56 ..
-rw-------    1 root     root           154 Jul 17 18:28 config
-rw-------    1 root     root           411 Jul 17 17:24 ha_gitlab_com_ed25519
-rw-------    1 root     root           102 Jul 17 17:24 ha_gitlab_com_ed25519.pub
➜  ~ cat /config/.ssh/config
Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/ha_gitlab_com_ed25519
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
➜  ~ 

Note : hardcoding IdentityFile to /tmp instead of ~ doesn't change anything dince the config does not get read at all.

  1. Restart tthe addon, verify that the key get copied in the addon's log
[2026-07-17T16:28:15.311Z] [ssh] Found SSH directory at /config/.ssh, setting up system SSH...
[2026-07-17T16:28:15.312Z] [ssh] Copied and secured: config
[2026-07-17T16:28:15.313Z] [ssh] Copied and secured: ha_gitlab_com_ed25519
[2026-07-17T16:28:15.314Z] [ssh] Copied and secured: ha_gitlab_com_ed25519.pub
[2026-07-17T16:28:15.314Z] [ssh] SSH setup complete
  1. Click "Push Now" in the addon, and get a Host key verification failed error.
[2026-07-17T16:28:48.869Z] [cloud-sync] Pushing main to origin/main...
[2026-07-17T16:28:49.201Z] [cloud-sync] Push failed: Error: Command failed: git push -f -u origin main:main
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    at genericNodeError (node:internal/errors:985:15)
    at wrappedFn (node:internal/errors:539:14)
    at ChildProcess.exithandler (node:child_process:417:12)
    at ChildProcess.emit (node:events:509:28)
    at maybeClose (node:internal/child_process:1124:16)
    at Socket.<anonymous> (node:internal/child_process:481:11)
    at Socket.emit (node:events:509:28)
    at Pipe.<anonymous> (node:net:351:12) {
  code: 128,
  killed: false,
  signal: null,
  cmd: 'git push -f -u origin main:main',
  stdout: '',
  stderr: 'Host key verification failed.\r\n' +
    'fatal: Could not read from remote repository.\n' +
    '\n' +
    'Please make sure you have the correct access rights\n' +
    'and the repository exists.\n'
}

Expected behavior
The same git push behavior as in the Terminal addon.

➜  /homeassistant git:(main) git push -u origin main
Enumerating objects: 249, done.
Counting objects: 100% (249/249), done.
Delta compression using up to 4 threads
Compressing objects: 100% (191/191), done.
Writing objects: 100% (249/249), 114.87 KiB | 114.88 MiB/s, done.
Total 249 (delta 48), reused 249 (delta 48), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (48/48), done.
To gitlab.com:Griffures/my_repo_name.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

Screenshots

HOME is /root, /root/.ssh does not exists, and keys are in /tmp/.ssh :

Image

ssh -vvv ... show it looks in /root/.ssh/ (documented behavior in newer OpenSSH: the client resolves ~ via passwd DB, not $HOME):

Image

Desktop (please complete the following information):

  • OS: HAOS
  • Addon Version 1.2.3

Additional context

LLM ran on the repo suggest modifying server.js:75-78 to set process.env.HOME = '/root' instead of /tmp. Then setupSshKeys() would copy to /root/.ssh/, which is where ssh actually looks.
Fix looks quite simple and credible, but has not been tested by myself. Do we need the the .gitconfig in /tmp rather than /root ?

If we don't, fix is simple. If we do, then either the file or .ssh/ needs to be hardcoded to /tmp or /root respectively and not depend on HOME.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions