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
  3. 64
      package.json

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]");
}
}

64
package.json

@ -1,34 +1,34 @@
{
"name": "wetty",
"version": "0.2.0",
"dependencies": {
"express": "3.5.1",
"socket.io": "^1.3.7",
"pty.js": "^0.3.0",
"optimist": "^0.6"
},
"devDependencies": {
"load-grunt-tasks": "^3.0",
"grunt": "^0.4",
"grunt-shell": "^1.1",
"grunt-mkdir": "^0.1",
"grunt-git": "^0.3",
"grunt-contrib-clean": "^0.6"
},
"description": "Wetty = Web + tty. Terminal access in browser over http/https ",
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/krishnasrinivas/wetty.git"
},
"author": "Krishna Srinivas <krishna.srinivas@gmail.com> (https://github.com/krishnasrinivas)",
"license": "MIT",
"bugs": {
"url": "https://github.com/krishnasrinivas/wetty/issues"
},
"homepage": "https://github.com/krishnasrinivas/wetty",
"preferGlobal": "true",
"bin": {
"wetty": "./bin/wetty.js"
}
"name": "wetty",
"version": "0.2.0",
"dependencies": {
"express": "3.5.1",
"socket.io": "^1.3.7",
"pty.js": "^0.3.0",
"optimist": "^0.6"
},
"devDependencies": {
"load-grunt-tasks": "^3.0",
"grunt": "^0.4",
"grunt-shell": "^1.1",
"grunt-mkdir": "^0.1",
"grunt-git": "^0.3",
"grunt-contrib-clean": "^0.6"
},
"description": "Wetty = Web + tty. Terminal access in browser over http/https ",
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/krishnasrinivas/wetty.git"
},
"author": "Krishna Srinivas <krishna.srinivas@gmail.com> (https://github.com/krishnasrinivas)",
"license": "MIT",
"bugs": {
"url": "https://github.com/krishnasrinivas/wetty/issues"
},
"homepage": "https://github.com/krishnasrinivas/wetty",
"preferGlobal": "true",
"bin": {
"wetty": "./bin/wetty.js"
}
}

Loading…
Cancel
Save