views:

127

answers:

2

I know there is an implementation of VNC using WebSockets (http://novnc.com) but that still requires a server. I am looking to create a simple client-side JavaScript only (no Flash) connection to a port running SSH. I am guessing WebSockets is the only way to go since it does TCP. Any example code? Any other way?

+2  A: 

You can take a look at serfish. It's a solution to access a SSH server. But if you're hosting your web application on the same server as your ssh, there are other solutions such as shell in a box.

Colin Hebert
Serfish uses a server to tunnel commands typed in the browser to the ssh host. shellinabox similarly needs to run on the host for the front-end browser-terminal to work. Is there anyway to emulate the terminal on client-side using JS only without writing any server (or ssh host) side code?
wrick
+2  A: 

Sorry, given your constraints (client-side Javascript only), there is no way to connect to a plain old SSH server.

WebSockets is not plain TCP. It's a framed protocol with a HTTP-like handshake between the client and server that includes origin policy.

Flash can make plain TCP connections, but it also has origin policy enforcement. The way it does this is by making a connection to the same server on port 843 and asking for a special XML file that contains the origin policy. If you are willing to relax your constraints slightly such that you are willing to run a generic WebSockets to TCP proxy either on a server (any server) or on the client then you can do what you are wanting to do. noVNC includes a C and python WebSockets to TCP proxy: http://github.com/kanaka/noVNC/tree/master/utils/.

Other info you might find useful:

kanaka