Config file in .ssh not been created which is leading to know_hosts verification fail

Hello,

We are running a Node-RED image using Docker, and most of the functions seem to be working fine. However, we're experiencing an issue with Git operations. We have a Git project that we use to store our flows. The problem is that whenever we restart the Node-RED container, the known_hosts verification fails.

We have mounted the .ssh folder to save the SSH keys, and I have verified that the permissions are fine. However, the same issue persists. In the debug logs, I can see that it's unable to access the config in the .ssh file. Even before the restart, I notice that no config file is being created, so I'm not entirely sure about the root cause.

There is a workaround where we can create a fresh SSH key, and it works. However, I would like to understand what I'm doing wrong in the current setup.

logs :

9 Jul 11:53:19 - [debug] git -c credential.helper= push origin HEAD:main --porcelain

9 Jul 11:53:19 - [debug] [err] Can't open user config file /home/node-red/.ssh/config: No such file or directory

9 Jul 11:53:19 - [debug] [err] fatal: Could not read from remote repository.

9 Jul 11:53:19 - [debug] [err]

9 Jul 11:53:19 - [debug] [err] Please make sure you have the correct access rights

9 Jul 11:53:19 - [debug] [err] and the repository exists.

9 Jul 11:53:19 - [debug] rc=128

1 Like

Hi there,

It sounds like you’re almost there with your setup — thanks for sharing the detailed logs and context, it really helps.
it seems the Git process is expecting a config file inside the .ssh directory, and while it's not strictly required for SSH to work, its absence can sometimes cause SSH or Git clients to behave inconsistently — especially in containerized environments where permissions and file presence can impact behavior more than expected.

You can approach as below steps

  1. Create an empty SSH config file

Even if you don’t need custom SSH options, try creating an empty config file inside the mounted .ssh directory:

touch /path/to/your/host/.ssh/config
chmod 600 /path/to/your/host/.ssh/config

Make sure this is owned by the same user that Node-RED runs as inside the container (likely node-red or UID 1000), and that your Docker volume mounts .ssh correctly to /home/node-red/.ssh.

Verify known_hosts persistence

Sometimes the issue isn’t with the config, but with the host fingerprint verification being lost between container restarts. Check that known_hosts is preserved properly:

ssh-keyscan github.com >> /path/to/your/host/.ssh/known_hosts

(Replace github.com with your Git server if it's private.)

This ensures the container doesn’t prompt for manual fingerprint confirmation each time it restarts.

Double-check Docker volume mount

Ensure you're mounting .ssh before the container starts, and to the right path:

volumes:
  - /your/host/.ssh:/home/node-red/.ssh

If .ssh doesn’t exist inside the container at that path during startup, Git won’t find your keys or config.

Run as correct user

If Node-RED inside the container is running as a different user (not node-red), it might not have access to /home/node-red/.ssh. You can confirm this by inspecting the user ID inside the container:

docker exec -it <container> whoami

You may need to match the UID of the mounted .ssh files accordingly.


Let us know if this helps or if you'd like to share your Dockerfile or docker-compose.yml — happy to take a look and help dig deeper.

Cheers!