Description
Electron SSH2 client and server modules written in pure JavaScript for node.js.
Rewriting for Electron Based on SSH2. For more details, please read the SSH2 document.
Requirements
- node.js -- v5.2.0 or newer
- node v12.0.0 or newer for Ed25519 key support
Installation
npm install electron-ssh2
Client Examples
uptime
on a server
Execute The following is a partial configuration based on SSH2. See the SSH2 documentation for more configurations
var Client = Client; var conn = ;conn; // example output:// Client :: ready// STDOUT: 17:41:15 up 22 days, 18:09, 1 user, load average: 0.00, 0.01, 0.05//// Stream :: exit :: code: 0, signal: undefined// Stream :: close
Start an interactive shell session
var Client = Client; var conn = ;conn; // example output:// Client :: ready// STDOUT: Last login: Sun Jun 15 09:37:21 2014 from 192.168.100.100//// STDOUT: ls -l// exit//// STDOUT: frylock@athf:~$ ls -l//// STDOUT: total 8//// STDOUT: drwxr-xr-x 2 frylock frylock 4096 Nov 18 2012 mydir//// STDOUT: -rw-r--r-- 1 frylock frylock 25 Apr 11 2013 test.txt//// STDOUT: frylock@athf:~$ exit//// STDOUT: logout//// Stream :: close
Send a raw HTTP request to port 80 on the server
var Client = Client; var conn = ;conn; // example output:// Client :: ready// TCP :: DATA: HTTP/1.1 200 OK// Date: Thu, 15 Nov 2012 13:52:58 GMT// Server: Apache/2.2.22 (Ubuntu)// X-Powered-By: PHP/5.4.6-1ubuntu1// Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT// Content-Encoding: gzip// Vary: Accept-Encoding// Connection: close// Content-Type: text/html; charset=UTF-8////// TCP :: CLOSED
Forward local connections to port 8000 on the server to us
var Client = Client; var conn = ;conn; // example output:// Client :: ready// Listening for connections on server on port 8000!// (.... then from another terminal on the server: `curl -I http://127.0.0.1:8000`)// TCP :: INCOMING CONNECTION: { destIP: '127.0.0.1',// destPort: 8000,// srcIP: '127.0.0.1',// srcPort: 41969 }// TCP DATA: HEAD / HTTP/1.1// User-Agent: curl/7.27.0// Host: 127.0.0.1:8000// Accept: */*////// TCP :: CLOSED