Python SSH Interactive Shell call back on data receive

125 views Asked by At

I'm trying to implement a interactive SSH shell using python as back-end. Basically I want to pass each character to shell along with and special character like new line, Ctrl-C. Then pass back the result. I found similar solution in node.js at Connecting to remote SSH server (via Node.js/html5 console) I can establish a websocket from fronend/JS side and send each character on key-press. But I'm facing problem in getting shell output back. In node.js ssh2 package its looks like on receiving data it can call some function

    }).on('data', function(data) {
      console.log('STDOUT: ' + data);
    }).stderr.on('data', function(data) {
      console.log('STDERR: ' + data);
    });

I checked the python's ssh2-python and Paramiko, but in both I see we have to loop continuously and check if any data is available on channel. Do we have something like callback similar to node.js ? So that I can handle incoming stream + continuous outgoing stream( in case of command like top and ping)

0

There are 0 answers