dev-master
9999999-devSSH terminal over web sockets
MIT
The Requires
The Development Requires
ssh web-sockets
1.0.0
1.0.0.0SSH terminal over web sockets
MIT
The Requires
The Development Requires
ssh web-sockets
SSH terminal over web sockets
Interactive terminals over websockets with a php backend. It can for instance be used to create interactive SSH sessions, but should work with any command. At the same time, an existing php backend can be used to perform authorization and authentication., (*1)
Uses the following tech:, (*2)
, (*3)
The project consists of a PHP backend which manages the client connections, and a frontend which
emulates the terminal. In order to run the backend server, create a composer dependency on this project,
and follow the example in ./server.php
:, (*4)
composer require magnusjt/socketty
Here you can customize:, (*5)
Backend example:
See ./server.php
, (*6)
Frontend:
Install by adding the following to npm dependencies:
"socketty": "git://github.com/magnusjt/socketty.git#master"
, (*7)
Frontend example (needs to be compiled with browserify and babelify):, (*8)
var Socketty = require('socketty'); var domNodeId = 'app'; // ID of the dom node to open the app in var wssUrl = 'wss://localhost:5678'; // Websocket URL // Create some presets var opts = [ { name: 'SSH', open: true, list: [ {cmd: 'ssh vagrant@127.0.0.1', 'name': 'Vagrant SSH'}, ] }, { name: 'Ping', open: false, list: [ {cmd: 'ping 127.0.0.1', 'name': 'Ping localhost'}, ] } ]; Socketty.start(domNodeId, wssUrl, opts);
npm install
.composer install
vagrant up
php server.php
gulp build
and gulp watchify
NB: apache and haproxy may need to be started manually after a reboot:, (*9)
service httpd start /usr/local/sbin/haproxy -f /vagrant/haproxy.cfg -p /var/run/haproxy.pid -D
In order to have secure web sockets, the vagrant install includes haproxy which terminates all ssl requests., (*10)
First of all, reactphp is used together with an event loop to acheive async calls with PHP. A sub component of reactphp called child-processes uses PHP's proc_open to connect to a child process and its pipes. For programs that require a tty (such as ssh and its interactive password prompt), we would really like to use PHP's pty pipes, but these are sadly not available on most systems. To get around this, all comands are opened through a python script, which uses the pty module to simulate a pty., (*11)
SSH terminal over web sockets
MIT
ssh web-sockets
SSH terminal over web sockets
MIT
ssh web-sockets