[ANNOUNCE]node-red-contrib-xterm : second beta (sidebar)

Hi folks,

Last month I announced the first beta of my new node-red-contrib-xterm node, which integrated a terminal window inside a custom node. That terminal window allowed users to execute command line commands, via your flow editor.

But Steve (@shrickus) suggested that this terminal window should have been inside the flow editor sidebar, instead of in a node's config screen. Very good proposal, but writing my first sidebar node became a hell of a job. Since I had to start from scratch again ( :weary: ), I have started this new discussion to avoid users becoming confused with the first beta ...

So LOTS of changes:

  • The terminal window is now inside a sidebar tabsheet.
  • You can manually start / stop / clean the terminal via buttons.
  • All kind of server side information and errors are now also displayed inside the terminal window.
  • It should run on macOS, Linux and Windows. I have only tested it on Windows and Raspbian, so would be nice if somebody could test it on macOS!
  • The look-and-feel of the terminal window is customizable.
  • Your favorite commands can be stored in Terminal Input nodes. :partying_face: :champagne:
  • Critical commands can be secured with a confirmation dialog.
  • It is possible to store a sequence of multiple commands, to store your own scripts.
  • Pre-build libraries are included (for the pseudo terminal code) for a number of systems, to avoid headache during installation.
  • ...

You can install it directly from my Github repository, since it is not published on NPM yet:

npm install bartbutenaers/node-red-contrib-xterm

First demo to show how the sidebar tabsheet works:

And a second demo to show how you can use Terminal Input nodes to store your favorite commands in your Node-RED flow:

More demo's are available on my Github repository (link above).
As usual all 'constructive' feedback is more than welcome!

Hope you like this node as much as I do ...
Have fun!

Bart

7 Likes

Just a note for anyone trying this on an Oracle Cloud Free Instance - you'll need to install git and gcc-c++ (which uses yum instead of apt)

sudo yum install git
sudo yum install gcc-c++

before running the npm command

Once it was installed - the first time I ran it - I got a message about did I want to leave, but it seems to work the second time I pressed play
image

Maybe spoke too soon - I got this when I switched back to viewing it
image

but worked again when I pressed play and did a ps aux

Hey Simon,
Thanks for testing it!!

I use these prebuild binaries under the cover: node-pty-prebuilt-multiarch:

image

I assume your os isn't available in that table? Not sure if you can ask those guys to add your platform ...

So the first time you press on the "Start" button, you get a popup with a message? Or a message inside the terminal screen, or ... ?

And you still remember what is was about?

Could you please explain what you have done in between? So you have opened your flow editor, done something else (with terminal tabsheet still open or switched to another tabsheet?), and when you came back the pseudoterminal had been stopped.

There is also a heartbeat every 5 seconds, send by the flow editor to the backend: when the backend doesn't get a heartbeat signal within 5 seconds, it decides that the flow editor has been closed (so it will close the pseudo terminal). Don't know whether that is perhaps the cause... I will make a change tonight so it will display "Pseudoterminal has been stopped due to heartbeat" in that situation. Then we have at least a bit more information for troubleshooting.

Perhaps my 5 seconds are a bit too optimistic if you use a cloud solution...
Thought all you guys were Raspberry freaks :wink:

@BartButenaers

Amazing!!!

1 Like

It was a standard Node-RED type dialog that you get at the top - can't remember details

I just switched back to using my Win10 PC (I view Node-RED instances including this one via a Pi4 - I VNC into Pi4 and run browser from there)

I'll test it then

I am but can't see need for this on my Pi as I VNC into them all so easy to run terminals

But with Oracle Cloud Free Instances, it's a nightmare to get to terminal as its needs ssh certificate (took me 1 hour to find out which machine at my end I'd set it up from!)

So having terminal inside Node-RED could be handy

Also, could be a security risk as if anyone cracks my Node-RED admin password - they've got access to the cloud instance

I'm sure @TotallyInformation will be along shortly to tell me off! :slight_smile:

2 Likes

BTW Julian already has given some basic feedback about security for my first beta version.

2 Likes

If you guys don't get it by now, you're a lost cause :rofl:

6 Likes

Not at all!

Almost all of my node-RED flows now run on the Oracle Cloud Free Instance.
It's faster, less downtime and has better web connectivity than my Pi.
I only use my pi as a MQTT broker and run node-RED locally purely for administrative functions such as updating my Pi's DNS IP. (you get a fixed IP address for the Oracle instances).

The OS used is 'Oracle Linux 7.7'

Hey Simon,
There is a new version on Github with following changes:

  • The sidebar sends a heartbeat every 5 seconds, but the server will wait 15 seconds (and then the pseudo terminal will be stopped). Perhaps that can solve your issue...

  • The info panel of the Terminal-Input node now contains a security warning:

    image

  • Before the terminal is started, the same security warning will also appear:

    xterm_security_warning

  • There is now a security section in the head of my readme page:

    image

    @TotallyInformation: is there anything else that pops up in your mind?

  • When the pseudo terminal is stopped (on the server), one of the following stop reasons will be returned:

    • heartbeat
    • (re)start button
    • exit command
    • SIGINT
    • stop button

    Short demo when pseudo terminal is being stopped, by clicking on the "Stop" button:

    xterm_stop_reason

QUESTION: By talking about security, I am now wondering if my httpAdmin endpoint is secured enough:

RED.httpAdmin.get('/xterm_shell/:terminal_id/:command/:info', function(req, res) {

Or should I do something special for permissions, to avoid that everybody can call the endpoint?

JFI - I decided I'd try and update it using itself as the terminal - but when I pressed play - I got no reponse at all

(This was before I'd updated it)
So I stopped Node-RED from a standard ssh session - updated the node and restarted NR and it worked fine
image

No timeouts on this version - I've been out shopping and come back and its still alive :slight_smile:image

That is living on the edge...
Will have a look at it later.

Unless you have been shopping less than 15 seconds, I call this good news :rofl:

Thanks for all your (constructive) feedback, and my best wishes for 2020!
Your Blockly question is on my agenda for next week :wink:

Nice Bart, it's working well on my Manjaro laptop!

1 Like

This was before I updated - it was on the old version - I was just letting you know

We both know that nothing is going happen with blocky :frowning:

It is yesterday's forgotten node :frowning:

Spoke too soon. The first time I open the editor and go to the terminal window and press "play" the terminal tab just closes. second time it's fine and opens the terminal.

I hit the same thing on both my mac and a pi

Hey Garry,
Do you mean the black terminal window closes or the tabsheet itself? Any errors in the browser console log?

The black terminal window opens briefly and then the tabsheet closes, when I open the tabsheet again the terminal window is not open but the play button opens it correctly.