31

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?

5 Answers 5

17

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:

5
5

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.

1
  • 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?
    – pathikrit
    Oct 10, 2010 at 1:17
4

For those still searching, paramikojs could be the answer.

I'm currently having a similar issue:I need a SSH JS client-side implementation, and I need it to be BSD licensed. Alas paramikojs seems to be GPL licensed.

1
  • 4
    From the readme: Before you ask, no this doesn't work on regular web pages.
    – Tamlyn
    Nov 4, 2014 at 11:07
1

Yes you can

  1. Install SSH server on your server

  2. Write a server side program (could be in PHP) that uses SSH client in the background

  3. Redirect messages between the SSH client (that probably has been residing in the same server as SSH server) and the JavaScript program in the web browser other side of the internet.

That server side program acts like a postman only and the java script program in the browser is just another postman between the user and server program.

(SSH server)<->(SSH client)<->(PHP e.g)<->(JavaScript)

Also don't forget that in the JavaScript program could have use Ajax for better mechanism. Also SSH client might be not completely and absolutely necessary because that PHP server side program could directly connect to SSH server

1
  • Better formatting makes your answer more clear.
    – Sevan
    Dec 24, 2021 at 20:17
0

It's definitely possible using a Linux emulator with full network support like the great OpenRISC emulator jor1k.

Note that I've created browser-tools.net, a collection of in-browser tools from number of different projects.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.