JavaUser
JavaUser

Reputation: 26354

How SSH X11 forwarding is achieved over the browser

I am planning to implement the functionality given by SSH -X . This is used to open GUI based application remotely. So I want to understand what are the components involved and should be implemented. I know how to setup this like starting VNC server in the host and assign DISPLAY variable. And do SSH -X connection from remote client and execute the required GUI app shell script (for example xeyes, xclock etc.,).Please share if anyone is having more advanced information. My requirement is to design a web based "SSH X" client. There are lot of tools available in the market for Web SSH but no tools with SSH X11 forwarding support.

Upvotes: 0

Views: 4024

Answers (1)

bk2204
bk2204

Reputation: 76579

The X11 protocol is intrinsically network transparent, so ssh -X simply sets up a port on the remote system and sets the DISPLAY variable so that X programs write the X11 protocol to that port, which it then streams back to the local side. (This is a simplification; there's also authentication involved.)

If you want to do this in the browser, you'll first have to have some sort of server-side component that does the SSH operations and converts the stream of data to something the browser can use. Browsers do not allow opening arbitrary TCP ports to remote systems in JavaScript, since doing so is a massive security risk.

You'll also have to find some way to render the X11 protocol in the browser. Essentially you'll be implementing a web-based X server (hopefully in something like WebAssembly). You should read the existing specifications for that and look at popular open-source X11 implementations, such as Xorg.

I should point out that this is a colossal amount of work due to the requirement to implement a full X server. VNC-based protocols are much simpler because they don't need to implement drawing primitives, only render (possibly compressed) images streams on the screen.

Upvotes: 3

Related Questions