Browse Source

Use SSH wrapper only if no username is known otherwise

pull/137/head
Oleg Kurapov 7 years ago
parent
commit
3237f49700
  1. 3
      wetty.mjs

3
wetty.mjs

@ -40,13 +40,14 @@ function getCommand(socket, sshuser, sshhost, sshport, sshauth) {
const { request } = socket; const { request } = socket;
const match = request.headers.referer.match('.+/ssh/.+$'); const match = request.headers.referer.match('.+/ssh/.+$');
const sshAddress = sshuser ? `${sshuser}@${sshhost}` : sshhost; const sshAddress = sshuser ? `${sshuser}@${sshhost}` : sshhost;
const sshPath = sshuser || match ? 'ssh' : path.join(__dirname, 'bin/ssh');
const ssh = match ? `${match[0].split('/ssh/').pop()}@${sshhost}` : sshAddress; const ssh = match ? `${match[0].split('/ssh/').pop()}@${sshhost}` : sshAddress;
return [ return [
process.getuid() === 0 && sshhost === 'localhost' process.getuid() === 0 && sshhost === 'localhost'
? ['login', '-h', socket.client.conn.remoteAddress.split(':')[3]] ? ['login', '-h', socket.client.conn.remoteAddress.split(':')[3]]
: [ : [
path.join(__dirname, 'bin/ssh'), sshPath,
ssh, ssh,
'-p', '-p',
sshport, sshport,

Loading…
Cancel
Save