Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Javascript example

  • Loading branch information...
commit df6c86b1586806f31475305d75005f251fb62b34 1 parent 90ff73b
@aluzzardi authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 examples/client.js
View
31 examples/client.js
@@ -0,0 +1,31 @@
+var client = new WSSHClient();
+
+client.connect({
+ // Connection and authentication parameters
+ username: 'root',
+ hostname: 'localhost',
+ authentication_method: 'password', // can either be password or private_key
+ password: 'secretpassword', // do not provide when using private_key
+ key_passphrase: 'secretpassphrase', // *may* be provided if the private_key is encrypted
+
+ // Callbacks
+ onError: function(error) {
+ // Called upon an error
+ console.error(error);
+ },
+ onConnect: function() {
+ // Called after a successful connection to the server
+ console.debug('Connected!');
+
+ client.send('ls\n'); // You can send data back to the server by using WSSHClient.send()
+ },
+ onClose: function() {
+ // Called when the remote closes the connection
+ console.debug('Connection Reset By Peer');
+ },
+ onData: function(data) {
+ // Called when data is received from the server
+ console.debug('Received: ' + data);
+ }
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.