# New take on interactive SSH - @insectos/ssh-exec

**URL:** <https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769>\
**Category:** Share Your Nodes\
**Created:** [24 August 2023 10:01 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769 "2023-08-24T10:01:15Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [24 August 2023 10:01 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/1 "2023-08-24T10:01:15Z")

</div>

> **[@insectos/ssh-exec](https://www.npmjs.com/package/@insectos/ssh-exec)**
>
> A flexible SSH client for Node-RED. Latest version: 0.3.0, last published: 2 days ago. Start using @insectos/ssh-exec in your project by running \`npm i @insectos/ssh-exec\`. There are no other projects in the npm registry using @insectos/ssh-exec.

Highlights:

- reads the .ssh/config to present target hosts
- only connects on first data send
- can switch target hosts through `msg.sshshost` parameter

feedback is apprechiated

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [24 August 2023 12:19 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/2 "2023-08-24T12:19:35Z")

</div>

Is there a reason you didn't use 'node-red-contrib...' in the name?

What makes it different from the other ssh nodes?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 August 2023 13:05 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/3 "2023-08-24T13:05:08Z")

</div>

> [@zenofmud](#):
>
> Is there a reason you didn't use 'node-red-contrib...' in the name?

The new guidelines dont insist on `node-red-contrib-xxx` format. The preferred format is a scoped name. see [Introducing the Node Scorecard : Node-RED](https://nodered.org/blog/2022/01/31/introducing-scorecard) 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 August 2023 14:51 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/4 "2023-08-24T14:51:00Z")

</div>

> [@Steve-Mcl](#):
>
> The preferred format is a scoped name. see [Introducing the Node Scorecard : Node-RED](https://nodered.org/blog/2022/01/31/introducing-scorecard) 🙂

Yes, but it does recommend, or at least suggest, including node-red in the name  
"If you use a scoped name, there are no further requirements on the name. You could use `@myScope/node-red-sample` or just `@myScope/sample` - although having `node-red` in the name does help to associate the module with the project."

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [24 August 2023 14:52 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/5 "2023-08-24T14:52:56Z")

</div>

I know it's not required but if I were looking for a SSH node via google I'd use 'Node-red ssh' and that node is not going to be on the first page of results. I like having node-red-contrib... as part of the name, it allows me to find things easily.

Just my opinion.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 August 2023 14:57 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/6 "2023-08-24T14:57:16Z")

</div>

> [@Colin](#):
>
> Yes, but it does recommend, or at least suggest, including node-red in the name

Indeed & why i linked to the docs.

My comment was more about the question Paul asked...

> [@zenofmud](#):
>
> Is there a reason you didn't use 'node-red-contrib...'

... in particular the `-contrib` part.

  

> [@zenofmud](#):
>
> I like having node-red-contrib... as part of the name, it allows me to find things easily.

I dont completely disagree (minus the contrib part).

For future custom nodes I do - I personally intend on keeping the `node-red` part (dropping the contrib part)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 August 2023 15:09 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/7 "2023-08-24T15:09:51Z")

</div>

> [@Steve-Mcl](#):
>
> For future custom nodes I do - I personally intend on keeping the `node-red` part (dropping the contrib part)

That is my intention also.

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [30 August 2023 07:21 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/8 "2023-08-30T07:21:03Z")

</div>

Naming has benn discussed... now to the differences:

- Ability to pick an SSH hostname from ~/.ssh/config, effectively abstracting it away from the flow
- Support for SSH keys when using a host from config
- Password classified as credential (so properly encrypted)
- Connection only gets established when actually data is sent
- Abillity to change the hostname through a value in msg

We use this as configuration mechanism for servers out in our farms. An operator (or an event) picks a farm from a list and sends commands. So instead of requiring one node per farm and resulting n open connections, we only need one that opens when needed

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [30 August 2023 09:29 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/9 "2023-08-30T09:29:07Z")

</div>

Installed the node on my Mac Mini M1 and imported the example flow. As soon as I deploy I get:

```auto
Flows stopped due to missing node types.

* ssh-exec

```

Thoughts?

UPDATE: I went to remove the node and see this  
 ![Screenshot 2023-08-30 at 5.35.50 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3efb25f3bece1146b6bc9564f510d5727b929896.png)

It would be nice to see that somewhere else than when trying to remove the node...  
maybe allow the location to be customizable as on the Mac it is `.ssh/known_hosts`

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [31 August 2023 13:54 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/10 "2023-08-31T13:54:17Z")

</div>

Ahhh nice catch. I'll add a check fo that file. `.ssh/known_hosts` serves a different purpose than `.ssh/config`, don't confuse the two. I develop on Mac & Linux an the file you want is `.ssh/config`

## `.ssh/config`

```bash
Host git fortress
    Hostname github.com
    IdentityFile ~/.ssh/gitkey_stwissel
    User Stwissel
    Port 22
    IdentitiesOnly yes

```

(not all entries are needed)

## `.ssh/known_hosts`

```bash
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl

```

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [31 August 2023 14:20 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/11 "2023-08-31T14:20:05Z")

</div>

0.3.1 with file check is out

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [31 August 2023 18:12 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/12 "2023-08-31T18:12:30Z")

</div>

I've created the .ssh/config file and from a terminal on the Mac it works fine, I can access on of my local pi's with

```auto
paul@PaulsM1 ~ % ssh yellowpi
Linux yellowpi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Aug 31 13:53:25 2023 from 2600:4040:5b24:4d00:988d:7b3:db83:5a73
pi@yellowpi:~ $ ls -al
total 322700
drwxr-xr-x 20 pi pi 4096 Aug 31 13:42 .
drwxr-xr-x 3 root root 4096 May 7 2021 ..
-rw------- 1 pi pi 17489 Aug 31 13:57 .bash_history
-rw-r--r-- 1 pi pi 220 May 7 2021 .bash_logout
-rw-r--r-- 1 pi pi 3523 May 7 2021 .bashrc
drwxr-xr-x 2 pi pi 4096 May 7 2021 Bookshelf

```

1. So I installed the latest version of your node and it shows 'yellow' in the `ssh Config` but why does it require the password when it is in the `.ssh/config`? Isn't that one of the purposes of the config file?
2. if I put in the password it remains disconnected
3. if I use `manual Host configuration` it works but outputs odd characters

```auto
drwxr-xr-x 3 root root 4096 May 7 2021 e[01;34m..e[0m
-rw------- 1 pi pi 17500 Aug 31 14:08 .bash_history
-rw-r--r-- 1 pi pi 220 May 7 2021 .bash_logout
-rw-r--r-- 1 pi pi 3523 May 7 2021 .bashrc
drwxr-xr-x 2 pi pi 4096 May 7 2021 e[01;34mBookshelfe[0m

```

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [4 September 2023 07:33 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/13 "2023-09-04T07:33:01Z")

</div>

The "odd characters" are control characters send by your SSH connection. Your terminal converts them into the colors you see. The ssh-node doesn't have a UI, so no conversion is happening, it's just the raw output.  
For passwords: I don't store them in config, since they are there in clear text. Credentials in NodeRED are encrypted, so it felt safer.

On your problem: did you have a user/password connection or did you use a key file? I've mostly tested with key files. Any chance you see the potential error in the log?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 September 2023 09:41 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/14 "2023-09-04T09:41:36Z")

</div>

> [@Stwissel](#):
>
> The "odd characters" are control characters send by your SSH connection. Your terminal converts them into the colors you see.

I suggest you change your sample flow to use  
`ls --color=never -al`

======================

> [@Stwissel](#):
>
> did you have a user/password connection or did you use a key file?

I use a IdentityFile

```auto
Host yellowpi 
HostName yellowpi.local
User pi 
IdentityFile ~/.ssh/id_rsa

```

======================  
But my question is: `in the node, why do I have to supply the password in the first place? Doesn't that defeat the purpose of creating a .ssh/config file?`

======================  
In addition how do I dynamically swap ssh hosts if I need to supply a password when it isn't documented in the the `Help`?

Currently if I set the node to `manual Host configuration` for `yellowpi` and include the password I can get data back. If I then set an `inject` node to include `msg.sshhost` when I run it I get

errMsg: `Error: All configured authentication methods failed`  
host: `undefined`

[UPDATE - 2022-09-06  
] I've started opening issues in GitHub about some of these problems.

---

<div class="post-metadata">

**Author:** ![Stwissel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stwissel/32/126_2.png) [@Stwissel](https://discourse.nodered.org/u/Stwissel)\
**Post date:** [8 September 2023 09:01 UTC](https://discourse.nodered.org/t/new-take-on-interactive-ssh-insectos-ssh-exec/80769/15 "2023-09-08T09:01:42Z")

</div>

Thx appreciate it. I’ll look at it on the weekend
