Browse Source

add wrapper for ssh to prompt for user login

pull/123/head
butlerx 8 years ago
committed by cbutler
parent
commit
502a9ded9c
No known key found for this signature in database GPG Key ID: 9EB3D625BD14DDEC
  1. 11
      app.js
  2. 17
      bin/ssh

11
app.js

@ -102,19 +102,26 @@ io.on('connection', function(socket){
}
var term;
if (process.getuid() == 0) {
if (process.getuid() == 0 && sshhost == 'localhost') {
term = pty.spawn('/usr/bin/env', ['login'], {
name: 'xterm-256color',
cols: 80,
rows: 30
});
} else {
} else if (sshuser) {
term = pty.spawn('ssh', [sshuser + sshhost, '-p', sshport, '-o', 'PreferredAuthentications=' + sshauth], {
name: 'xterm-256color',
cols: 80,
rows: 30
});
} else {
term = pty.spawn('./bin/ssh', [sshhost, '-p', sshport, '-o', 'PreferredAuthentications=' + sshauth], {
name: 'xterm-256color',
cols: 80,
rows: 30
});
}
console.log((new Date()) + " PID=" + term.pid + " STARTED on behalf of user=" + sshuser)
term.on('data', function(data) {
socket.emit('output', data);

17
bin/ssh

@ -0,0 +1,17 @@
#!/usr/bin/perl
my $user_at_address = $ARGV[0];
my @u_a = split(/@/, $user_at_address);
if (defined $u_a[1]) {
if ( $^O == 'linux' ) {
exec ("/usr/bin/ssh $u_a[0]\@$u_a[1]");
}
}
else {
print "Enter your username: ";
my $username = <STDIN>;
chomp ( $username );
if ( $^O == 'linux' ) {
exec ("/usr/bin/ssh $username\@$u_a[0]");
}
}
Loading…
Cancel
Save