Skip to contentSkip to conversation

Serial Over Lan in the webui

DISCUSSION Deepak Kodihalli 2 participants 3 messages Apr 13, 2018

lore
Share & tools
lore
#0 lore raw

Hi,

I'm investigating https://github.com/openbmc/openbmc/issues/2736, which is about enabling the SOL functionality in the webui (https://github.com/openbmc/phosphor-webui).

What the webui currently has is an embedded terminal emulator (hterm.js), although there's no ssh connection that's established to the host. Basically the SOL doesn't work in the UI.

Also there seems to be two ways in which you can run the UI in general - by downloading the webui code, building and running it via a Node server (using the node package manager, or npm), or having the REST server on the BMC serve up the webui code (html, javascript etc) when someone points their browser to https://<BMC>.

Based on my investigation, it might not be possible to get the SOL working in the UI via the latter scenario. This is because it doesn't seem to be possible to implement an ssh client with client-side html and javascript that a browser can run by itself, and that's because javascript running in the browser doesn't have raw tcp/ip socket support.

How a "web" ssh client is typically implemented is by using some kind of server-side scripting framework, something like Node. For eg I was able to get the SOL in the webui working (when I run it via Node of course) by implementing a Node server based on ssh2.js, which acts as a proxy server. I used socket.io.js to have the terminal and this proxy server communicate, the proxy server uses ssh2.js to implement an ssh client to connect to the sshd running on the bmc. The key here though is ssh2.js can't be executed by a browser (no raw tcp sockets), it requires network APIs provided by Node's (or some other server-side technology) runtime.

So the question is how do we solve this when the webui code is served by the BMC? Is anyone aware of a pure client-side javascript based ssh client? If not, we'd have to run Node or something equivalent on the BMC, or have the REST server act as a proxy server between the terminal writing to a socket that the rest server can intercept and convert to ssh packets. Any other thoughts on how this can be achieved?

Thanks,
Deepak

#1 lore raw

I sent you a few replies on IRC, not sure if you saw any of them. Some ideas are below.

Quoted 9 lines

-----Original Message-----
From: Deepak Kodihalli [mailto:[email protected]]
Sent: Friday, April 13, 2018 2:59 AM
To: [email protected]; Tanous, Ed <[email protected]>; [email protected]; [email protected]; Brad Bishop <[email protected]>
Cc: OpenBMC Maillist <[email protected]>
Subject: Serial Over Lan in the webui

Quoted 5 lines

Based on my investigation, it might not be possible to get the SOL working in the UI via the latter scenario. This is because it doesn't seem to be possible to implement an ssh client with client-side html and javascript that a browser can run by itself, and that's because javascript running in the browser doesn't have raw tcp/ip socket support.

To my understanding, there is no way to implement browser WebUI based SSH in either scenario without a separate conversion to websockets, as I do not believe there is any browser support for the low level socket access you need to directly connect to an SSH socket. As you said, you are running an intermediary on your development system to do this now, which doesn't work when deploying to the platform.

Quoted 3 lines

So the question is how do we solve this when the webui code is served by the BMC?

You will need some way to transfer events (text) to the browser. In order, my personal preference would be:

1. Build a daemon that is capable of forwarding socket-like information over an authenticated websocket. There are several examples of how to do this, Bmcweb has an example of sending VNC-like protocols over an authenticated websocket. Rest-dbus has a websocket for transferring dbus eventing info. You could use either of these as an example of how to build your own.
2. Use something like SSE to transfer the buffers and forward the events.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
3. Use long polling on a rest api to transfer buffers.
https://www.pubnub.com/blog/2014-12-01-http-long-polling/

Quoted 2 lines

Is anyone aware of a pure client-side javascript based ssh client? If not, we'd have to run Node or something equivalent on the BMC

You are free to do what you want, but I wouldn’t recommend this route, and would resist any attempts to put it in an upstream component patchset. NodeJS is very heavyweight for running on the BMC hardware, in both flash usage and startup time, as it's jit compiling its sources using V8. For something relatively simple (forwarding a serial interface to a websocket) I do not believe the infrastructure cost of maintaining nodejs on the BMC is warranted.

Quoted 4 lines

, or have
the REST server act as a proxy server between the terminal writing to a socket that the rest server can intercept and convert to ssh packets. Any other thoughts on how this can be achieved?

I would recommend going a level deeper, and avoid SSH altogether. Directly connect the websocket to the interface that the SSH daemon is sourcing serial from.`

#2 lore raw
Quoted 1 line · Ed

I sent you a few replies on IRC, not sure if you saw any of them. Some ideas are below.

Seem to have missed them.

Quoted 18 lines
Quoted 9 lines

-----Original Message-----
From: Deepak Kodihalli [mailto:[email protected]]
Sent: Friday, April 13, 2018 2:59 AM
To: [email protected]; Tanous, Ed <[email protected]>; [email protected]; [email protected]; Brad Bishop <[email protected]>
Cc: OpenBMC Maillist <[email protected]>
Subject: Serial Over Lan in the webui

Quoted 5 lines

Based on my investigation, it might not be possible to get the SOL working in the UI via the latter scenario. This is because it doesn't seem to be possible to implement an ssh client with client-side html and javascript that a browser can run by itself, and that's because javascript running in the browser doesn't have raw tcp/ip socket support.

To my understanding, there is no way to implement browser WebUI based SSH in either scenario without a separate conversion to websockets, as I do not believe there is any browser support for the low level socket access you need to directly connect to an SSH socket. As you said, you are running an intermediary on your development system to do this now, which doesn't work when deploying to the platform.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

So the question is how do we solve this when the webui code is served by the BMC?

You will need some way to transfer events (text) to the browser. In order, my personal preference would be:

1. Build a daemon that is capable of forwarding socket-like information over an authenticated websocket. There are several examples of how to do this, Bmcweb has an example of sending VNC-like protocols over an authenticated websocket. Rest-dbus has a websocket for transferring dbus eventing info. You could use either of these as an example of how to build your own.

I implemented that websocket for the alerts, but you're right that I should be able to leverage/refer to that implementation. I was going to try that first, but will look at the other ideas that you've suggested as well.

Quoted 8 lines

2. Use something like SSE to transfer the buffers and forward the events.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
3. Use long polling on a rest api to transfer buffers.
https://www.pubnub.com/blog/2014-12-01-http-long-polling/

Quoted 2 lines

Is anyone aware of a pure client-side javascript based ssh client? If not, we'd have to run Node or something equivalent on the BMC

You are free to do what you want, but I wouldn’t recommend this route, and would resist any attempts to put it in an upstream component patchset. NodeJS is very heavyweight for running on the BMC hardware, in both flash usage and startup time, as it's jit compiling its sources using V8. For something relatively simple (forwarding a serial interface to a websocket) I do not believe the infrastructure cost of maintaining nodejs on the BMC is warranted.

I agree, I just put that into perspective to stress the need of some server side work.

Quoted 6 lines
Quoted 4 lines

, or have
the REST server act as a proxy server between the terminal writing to a socket that the rest server can intercept and convert to ssh packets. Any other thoughts on how this can be achieved?

I would recommend going a level deeper, and avoid SSH altogether. Directly connect the websocket to the interface that the SSH daemon is sourcing serial from.`

That sounds like a good idea, thanks!

Regards,
Deepak