Node-Red cannot read my ssh key (in /home/pi/.ssh/id_rsa)

Hello everyone
I’m trying to control Kodi with Gladys via Node-RED over SSH.
For this I created an SSH key on Gladys’s Raspberry Pi and this key is located at
/home/pi/.ssh/id_rsa

However Node-RED cannot access this file.
On the web I found this

  1. Item

The following contrived example shows how a private key on the host machine can be read from a container.

docker run -it --rm -v ~/.ssh/id_rsa:/root/.ssh/id_rsa:ro ubuntu cat /root/.ssh/id_rsa

This should allow a process running as root to authenticate with your credentials.

  1. Item

A cross-platform solution is to use a bind mount to share the host’s .ssh folder with the container:

docker run -v /home/<host user>/.ssh:/home/<docker user>/.ssh <image>

Similar to agent forwarding, this approach will make the public keys available to the container. An additional benefit is that it also works with a non-root user and will allow you to connect to GitHub. One caveat to consider, however, is that all contents (including private keys) of the .ssh directory will be shared. This approach is therefore only desirable for development and only for trusted container images.

In the first example I don’t really see what to replace « ro ubuntu » with — maybe the Node-RED Docker image — and I don’t understand what « ro » means

Which would give
docker run -it --rm -v ~/.ssh/id_rsa:/root/.ssh/id_rsa:ro nodered/node-red cat /root/.ssh/id_rsa

For example 2
I think you should replace
<host user> with « pi » on the Raspberry
<docker user> with « admin » entry specified in /var/lib/node-red/settings.js
<image> with « nodered/node-red »

Which would give
docker run -v /home/pi/.ssh:/home/admin/.ssh nodered/node-red

And following Pierre-Gilles’ code this would be

docker run -d \
--log-opt max-size=10m \
--restart=always \
--privileged \
-u root \
--network=host \
--name node_red \
-v /var/lib/node-red:/data \
-v /home/pi/.ssh:/home/admin/.ssh \
nodered/node-red

I would like to know what you think of this before I go ahead with the changes.
Thank you.

If I’m not mistaken, « ro » should mean: read only.
And as for the rest, I’m still too much of a novice. But it seems to me that, among other things, it should be written like this:

-v /home/pi/.ssh:/home/admin/.ssh:ro

We’ll still wait for confirmation from people

I continued my investigation.
So I understood that <docker user> for Node-RED is node-red
Sources: Permissions and Persistence · node-red/node-red-docker Wiki · GitHub

Then https://docs.docker.com/storage/bind-mounts/
confirmed your information @dahut: « ro » does indeed mean read only

So for now I’d be inclined to do this:
-v /home/pi/.ssh:/home/node-red/.ssh:ro

I tested

docker run -d \
  -it \
  --name devtest \
  -v /home/pi/.ssh

So I ran the following configuration


docker run -d \\
--