SSH Node can't execute docker / sudo

Describe the issue/error/question

I am running n8n Version 0.168.0 via Docker on a Synology and have a problem with the SSH node: I want to use it to read Docker statistics from the host machine.

Commands like “ls” are executed without problems but a call of
echo PASSWORD|sudo -S docker stats --no-stream
can’t executed and gives a reply “Password: sudo: docker: command not found”.
The same user can execute the command under a native SSH without problems, so why n8n can’t execute docker?

Information on your n8n setup

  • n8n version: 0.168.0
  • Database you’re using (default: SQLite):default
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @rkt62,

Welcome to the community :partying_face:

Are you using the ssh node to access the host or localhost? The error itself looks to be coming from the OS rather than something generated I am not sure why it has password: before it though that almost looks like the command is wrong.

Hi Jon, thanks for your fast reply.
Yes, I try to use ssh to acces the host.
With the same credentials on “native ssh” the system-resonse looks like

[email protected]:~$ docker stats
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version”: dial unix /var/run/docker.sock: connect: permission denied

When I use the same command with the ssh-node I get:

[
   {
      "code": 127,
      "signal": null,
      "stdout": "",
      "stderr": "sh: docker: command not found"
   }
]

It seems that the ssh-node dont get the required path of a command on the host machine.

That is odd, Just done a quick test here… From my terminal I get

[email protected]:~$ docker stats
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied

If I run the same command with the SSH node I get…

If I change this a bit more to use the command you want to run (echo "removed" | sudo -S docker stats --no-stream) I get this:

I am not really sure what the differences are but I would say the issue is not with the node and maybe with the shell environment on the server :man_shrugging:

I did find if I run the sudo -S command from the terminal it would sometimes show the password prompt still and after a second would then show the listing so there could be something odd there with Bash or it could be where I didn’t have a space the first time round between the commands and the pipe.

1 Like

You gave me the right hint:
This seems to be a special problem of the SYNOLOGY operating system.
With specification of the path it works fine:
echo PASSWORD | sudo -S /usr/local/bin/docker stats --no-stream --format '{{json .}}'

Thanks for your assistance!

1 Like

That is good to hear :+1: