Is it possible to connect to SSH using JavaScript?

2020-02-20 07:00发布

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?

4条回答
三岁会撩人
2楼-- · 2020-02-20 07:29

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.

查看更多
对你真心纯属浪费
3楼-- · 2020-02-20 07:39

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.

查看更多
祖国的老花朵
4楼-- · 2020-02-20 07:44

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楼-- · 2020-02-20 07:45

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.

查看更多
登录 后发表回答