chjj / tty.js

A terminal for your browser, using node/express/socket.io
MIT License
4.19k stars 483 forks source link

multiple users and 1-to-1 mapping ? #143

Open wholeinsoul opened 9 years ago

wholeinsoul commented 9 years ago

Is it possible for a single tty.js server to support multiple users with each user mapped to a unique linux user ? Currently it seems all the users access the same linux user's shell.

I have userZ running the tty.js server and two users userA, userB specified in config.json. But both userA and userB end up having the access to userZ's shell [whoami returns userZ for both userA and userB]. How can I map userA to linux userA's shell and userB to linux userB's shell ?

One solution I can think of is to specify a custom shell in config.json "shell" : "my_shell_script" that logins into the appropriate user shell.

Thank you

chjj commented 9 years ago

Not right now, but pty.js has the ability to set the uid and gid of the forked process. So, it is technically possible to map each browser user to a unix user if implemented right. I think this is a good idea and shouldn't be too difficult to implement. Will accept PRs.

That being said, you could also set the default shell to a unix login. That way users would just login using the terminal. I haven't tested it myself, but I've heard of people doing it.

wholeinsoul commented 9 years ago

Thank you. I was also thinking of the unix login shell approach.

davicompu commented 9 years ago

chjj I would like to know how to setup tty.js or the inside implementation of pty for the default unix login. I'm currently running tty.js project because of the express server.

risacher commented 8 years ago

FWIW, I had trouble getting tty.js to use the default unix login, so set my shell parameter to be a tiny script that I call 'ssh-localhost' which looks like this:

#!/usr/bin/perl
print "Login: ";      
my $username = <STDIN>;
chomp $username;        
$username =~ s/[^a-z]//g;
exec ("/usr/bin/ssh -e none $username\@localhost"); 

This allows me to use tty.js to login as any user on the local host where tty.js is running.