# Node-Red cannot read my ssh key (in /home/pi/.ssh/id\_rsa)

**URL:** <https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035>\
**Category:** Configuration\
**Tags:** node-red\
**Created:** [March 23, 2023, 8:30pm UTC](https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035 "2023-03-23T20:30:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjm](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/bjm/32/1753_2.png) [@bjm](https://community.gladysassistant.com/u/bjm)\
**Post date:** [March 23, 2023, 8:30pm UTC](https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035/1 "2023-03-23T20:30:36Z")

</div>

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 «&nbsp;ro ubuntu&nbsp;» with — maybe the Node-RED Docker image — and I don’t understand what «&nbsp;ro&nbsp;» 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 «&nbsp; **pi** &nbsp;» on the Raspberry  
`<docker user>` with «&nbsp; **admin** &nbsp;» entry specified in `/var/lib/node-red/settings.js`  
`<image>` with «&nbsp; **nodered/node-red** &nbsp;»

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

And following Pierre-Gilles’ code this would be

```auto
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.

---

<div class="post-metadata">

**Author:** ![dahut](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dahut](https://community.gladysassistant.com/u/dahut)\
**Post date:** [March 23, 2023, 10:07pm UTC](https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035/2 "2023-03-23T22:07:06Z")

</div>

If I’m not mistaken, «&nbsp;ro&nbsp;» 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

---

<div class="post-metadata">

**Author:** ![bjm](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/bjm/32/1753_2.png) [@bjm](https://community.gladysassistant.com/u/bjm)\
**Post date:** [March 24, 2023, 6:50pm UTC](https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035/3 "2023-03-24T18:50:51Z")

</div>

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](https://github.com/node-red/node-red-docker/wiki/Permissions-and-Persistence)

Then [https://docs.docker.com/storage/bind-mounts/](https://docs.docker.com/storage/bind-mounts/)  
confirmed your information @dahut: «&nbsp;ro&nbsp;» 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

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

---

<div class="post-metadata">

**Author:** ![bjm](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/bjm/32/1753_2.png) [@bjm](https://community.gladysassistant.com/u/bjm)\
**Post date:** [March 24, 2023, 9:21pm UTC](https://community.gladysassistant.com/t/node-red-ne-peut-pas-lire-ma-cle-ssh-dans-home-pi-ssh-id-rsa/8035/4 "2023-03-24T21:21:23Z")

</div>

So I ran the following configuration

```auto

docker run -d \\
--
```
