Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to connect to SSH using JavaScript?

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?

like image 393
pathikrit Avatar asked Oct 09 '10 20:10

pathikrit


People also ask

Can you SSH through browser?

SSH-in-browser doesn't require any additional extensions or software. SSH-in-browser supports connections from VMs that store SSH keys in metadata, VMs that use OS Login, and VMs that use IAP for TCP forwarding.

What is SSH in node JS?

SSH is one such tool that allows users to securely connect to and control remote computers from the comfort of their homes. In this article, we are going to explore the basics of SSH and build an application in Node. js to connect to a virtual machine and monitor system health.


2 Answers

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:

  • Current WebSocket draft: https://datatracker.ietf.org/doc/html/draft-hixie-thewebsocketprotocol-76

  • Simple (insecure) way of running a flash policy server (Linux/UNIX with socat) is described here: http://github.com/kanaka/noVNC/blob/master/docs/flash_policy.txt

  • More info about the flash policy file: http://code.google.com/p/doctype/wiki/ArticleFlashSecurity

like image 84
kanaka Avatar answered Sep 24 '22 07:09

kanaka


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.

like image 37
Colin Hebert Avatar answered Sep 21 '22 07:09

Colin Hebert