user978734
user978734

Reputation: 303

Node.js Web-based SSH

Is there a way to launch process (bash) from node.js under specific user when knowing linux username and password of this user.

I want to transfer terminal from server over socket.io to web browser and I need every user to act under their usernames, so user permissions are acting like on proper ssh.

Upvotes: 0

Views: 1235

Answers (1)

user568109
user568109

Reputation: 47993

Basically you are sharing an SSH connection over the web.

You should spawn child processes from node.js inbuilt functionality child_process.spawn like the following:

var spawn = require('child_process').spawn; ls = spawn('ls', ['-lh', '/usr']);

see here: http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

To initiate each users SSH you should use :(in the child process spawn)

ssh -tt [email protected] [command_to_execute]

Rest is upto you to link the child process on node.js with the interface on webpage with your socket.io.js

Upvotes: 1

Related Questions