Using Expression for host of SSH-Node fails

Describe the problem/error/question

I created an SSH-Credential using {{$json.host}} as an expression for host.

But the expression is not evaluated correctly.
If hardcode an ip inside the credential everything ist working as expected for the single host, so the provided sshkey can’t be the reason it’s not working.

I need to loop over a list of hosts and execute an ssh comannd on each host.

Any Help is greatly appreciated.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Error: All configured authentication methods failed at doNextAuth (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/client.js:865:21) at tryNextAuth (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/client.js:1082:7) at USERAUTH_FAILURE (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/client.js:430:11) at 51 (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/handlers.misc.js:408:16) at Protocol.onPayload (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/Protocol.js:2059:10) at AESGCMDecipherNative.decrypt (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/crypto.js:987:26) at Protocol.parsePacket [as _parse] (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/Protocol.js:2028:25) at Protocol.parse (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/Protocol.js:313:16) at Socket.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/ssh2/lib/client.js:775:21) at Socket.emit (node:events:518:28)

Information on your n8n setup

  • n8n version: 1.82.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own): Own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu
1 Like

You can’t use expressions for setting up credentials. If you wish to dynamically generate credentials, you’d have to use a node where you can add the relevant data from the inputs. Not sure if it’s possible for SSH.

If your SSH server supports SSH over HTTPS, you can try using the HTTP request node for this.

as per docs this should work, this is why i tried it

Sorry, you’re right. As per the doc, it should work. But either the doc or the example is wrong because using that same workflow gives this error:

Referenced node doesn't exist

It shows the value correctly:

yet returns that error. That particular example was added last year:

not sure if something has changed since then.

Hi, any progress on this? I would say this is an absolutely essential feature. If I want to send commands to dozens of VMs, it can’t be the solution to add a credential entry for each VM. In my opinion, this makes the SSH functionality close to unusable, already on private environments.

For the Moment i ended Up creating ssh credentials for each VM resulting in a messy Workflow with Lots of ssh nodes. It works but isn`t really maintainable.

Don’t want this discussion to close automatically, but wanted to note that I am trying to accomplish the exact same thing (automate SSH commands to a group of servers).