keyboard-interactive handling
Added keyboard-interactive handling (thanks @mikej81). Also cleaned up some syntax, missing semicolons.
This commit is contained in:
parent
e08878d81a
commit
c5af044bbe
1 changed files with 12 additions and 8 deletions
20
index.js
20
index.js
|
@ -18,7 +18,7 @@ function checkParams(arr) {
|
|||
missing_params.push(arr[i]);
|
||||
}
|
||||
}
|
||||
if (missing_params.length == 0) {
|
||||
if (missing_params.length === 0) {
|
||||
next();
|
||||
} else {
|
||||
next(JSON.stringify({
|
||||
|
@ -26,7 +26,7 @@ function checkParams(arr) {
|
|||
"message": "Parameter(s) missing: " + missing_params.join(",")
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
server.listen({
|
||||
|
@ -49,13 +49,13 @@ app.use(express.static(__dirname + '/public')).use(term.middleware()).use(functi
|
|||
res.setHeader('WWW-Authenticate', 'Basic realm="WebSSH"');
|
||||
res.end('Username and password required for web SSH service.');
|
||||
} else {
|
||||
config.user.name = myAuth['name'];
|
||||
config.user.password = myAuth['pass'];
|
||||
config.user.name = myAuth.name;
|
||||
config.user.password = myAuth.pass;
|
||||
next();
|
||||
}
|
||||
}).get('/', checkParams(["host"]), function(req, res) {
|
||||
res.sendFile(path.join(__dirname + '/public/client.htm'))
|
||||
config.ssh.host = req.query.host
|
||||
res.sendFile(path.join(__dirname + '/public/client.htm'));
|
||||
config.ssh.host = req.query.host;
|
||||
if (typeof req.query.port !== 'undefined' && req.query.port !== null){ config.host.port = req.query.port;}
|
||||
if (typeof req.query.header !== 'undefined' && req.query.header !== null){ config.header.text = req.query.header;}
|
||||
if (typeof req.query.headerBackground !== 'undefined' && req.query.headerBackground !== null){ config.header.background = req.query.headerBackground;}
|
||||
|
@ -91,17 +91,21 @@ io.on('connection', function(socket) {
|
|||
socket.emit('status', 'SSH CONNECTION CLOSED');
|
||||
socket.emit('statusBackground', 'red');
|
||||
}).on('error', function(error) {
|
||||
socket.emit('status', 'SSH CONNECTION ERROR - ' + error)
|
||||
socket.emit('status', 'SSH CONNECTION ERROR - ' + error);
|
||||
socket.emit('statusBackground', 'red');
|
||||
}).on('keyboard-interactive', function(name, instructions, instructionsLang, prompts, finish) {
|
||||
console.log('Connection :: keyboard-interactive');
|
||||
finish([config.user.password]);
|
||||
}).connect({
|
||||
host: config.ssh.host,
|
||||
port: config.ssh.port,
|
||||
username: config.user.name,
|
||||
password: config.user.password,
|
||||
tryKeyboard: true,
|
||||
// some cisco routers need the these cipher strings
|
||||
algorithms: {
|
||||
'cipher': ['aes128-cbc', '3des-cbc', 'aes256-cbc'],
|
||||
'hmac': ['hmac-sha1', 'hmac-sha1-96', 'hmac-md5-96']
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue