mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-27 16:02:16 +03:00
Added SSH key support to mobile app.
This commit is contained in:
parent
6798415c92
commit
93a1b8e002
File diff suppressed because it is too large
Load Diff
@ -4635,11 +4635,19 @@
|
|||||||
switch (j.action) {
|
switch (j.action) {
|
||||||
case 'sshauth': {
|
case 'sshauth': {
|
||||||
var x = '';
|
var x = '';
|
||||||
x += addHtmlValue("Username", '<input id=dp2user style=width:190px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
x += addHtmlValue("Authentication", '<select id=dp2authmethod style=width:150px onchange=sshAuthUpdate(event)><option value=1 selected>' + "Username & Password" + '</option><option value=2>' + "Username and Key" + '</option></select>')
|
||||||
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:190px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
x += addHtmlValue("Username", '<input id=dp2user style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '<div id=d2passauth>';
|
||||||
|
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '</div><div id=d2keyauth style=display:none>';
|
||||||
|
x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:150px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />');
|
||||||
|
x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '</div>';
|
||||||
x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
|
x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
|
||||||
|
x += '<div id=d2keyauth2 style=font-size:x-small><br />' + "Key file must be in OpenSSH format." + '</div>';
|
||||||
setDialogMode(2, "Authentication", 11, sshConnectEx, x, 'ssh');
|
setDialogMode(2, "Authentication", 11, sshConnectEx, x, 'ssh');
|
||||||
setTimeout(sshAuthKeyUp, 50);
|
setTimeout(sshAuthUpdate, 50);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 'sshautoauth': {
|
case 'sshautoauth': {
|
||||||
terminal.socket.send(JSON.stringify({ action: 'sshautoauth', cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
|
terminal.socket.send(JSON.stringify({ action: 'sshautoauth', cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
|
||||||
@ -4653,12 +4661,36 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sshAuthKeyUp(e) { QE('idx_dlgOkButton', (Q('dp2user').value.length > 0) && (Q('dp2pass').value.length > 0)); }
|
function sshAuthUpdate(e) {
|
||||||
|
QV('d2passauth', Q('dp2authmethod').value == 1);
|
||||||
|
QV('d2keyauth', Q('dp2authmethod').value == 2);
|
||||||
|
QV('d2keyauth2', Q('dp2authmethod').value == 2);
|
||||||
|
if (Q('dp2authmethod').value == 1) {
|
||||||
|
QE('idx_dlgOkButton', (Q('dp2user').value.length > 0) && (Q('dp2pass').value.length > 0));
|
||||||
|
} else {
|
||||||
|
QE('idx_dlgOkButton', false);
|
||||||
|
var ok = (Q('dp2user').value.length > 0) && (Q('dp2key').files != null) && (Q('dp2key').files.length == 1) && (Q('dp2key').files[0].size < 8000);
|
||||||
|
if (ok == true) {
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
var validkey = ((e.target.result.indexOf('-----BEGIN OPENSSH PRIVATE KEY-----') >= 0) && (e.target.result.indexOf('-----END OPENSSH PRIVATE KEY-----') >= 0));
|
||||||
|
QE('idx_dlgOkButton', validkey);
|
||||||
|
}
|
||||||
|
reader.readAsText(Q('dp2key').files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function sshConnectEx(b) {
|
function sshConnectEx(b) {
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
if (terminal != null) { connectTerminal(); } // Disconnect
|
if (terminal != null) { connectTerminal(); } // Disconnect
|
||||||
} else {
|
} else {
|
||||||
|
if (Q('dp2authmethod').value == 1) {
|
||||||
terminal.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked, cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
|
terminal.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked, cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight }));
|
||||||
|
} else {
|
||||||
|
var reader = new FileReader(), username = Q('dp2user').value, keypass = Q('dp2keypass').value, keep = Q('dp2keep').checked;
|
||||||
|
reader.onload = function (e) { terminal.socket.send(JSON.stringify({ action: 'sshauth', username: username, keypass: keypass, key: e.target.result, keep: keep, cols: xterm.cols, rows: xterm.rows, width: Q('termarea3xdiv').offsetWidth, height: Q('termarea3xdiv').offsetHeight })); }
|
||||||
|
reader.readAsText(Q('dp2key').files[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4855,12 +4887,19 @@
|
|||||||
switch (data.action) {
|
switch (data.action) {
|
||||||
case 'sshauth': {
|
case 'sshauth': {
|
||||||
var x = '';
|
var x = '';
|
||||||
x += addHtmlValue("Username", '<input id=dp2user style=width:190px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
x += addHtmlValue("Authentication", '<select id=dp2authmethod style=width:150px onchange=sshAuthUpdate(event)><option value=1 selected>' + "Username & Password" + '</option><option value=2>' + "Username and Key" + '</option></select>')
|
||||||
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:190px maxlength=64 autocomplete=off onkeyup=sshAuthKeyUp(event) />');
|
x += addHtmlValue("Username", '<input id=dp2user style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '<div id=d2passauth>';
|
||||||
|
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '</div><div id=d2keyauth style=display:none>';
|
||||||
|
x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:150px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />');
|
||||||
|
x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:150px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
|
x += '</div>';
|
||||||
x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
|
x += '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>';
|
||||||
|
x += '<div id=d2keyauth2 style=font-size:x-small><br />' + "Key file must be in OpenSSH format." + '</div>';
|
||||||
setDialogMode(2, "Authentication", 11, p13sshConnectEx, x, 'ssh');
|
setDialogMode(2, "Authentication", 11, p13sshConnectEx, x, 'ssh');
|
||||||
setTimeout(sshAuthKeyUp, 50);
|
setTimeout(sshAuthUpdate, 50);
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
case 'autherror': { p13setConsoleMsg("Authentication Error", 5000); return; }
|
case 'autherror': { p13setConsoleMsg("Authentication Error", 5000); return; }
|
||||||
case 'connectionerror': { p13setConsoleMsg("Connection Error", 5000); return; }
|
case 'connectionerror': { p13setConsoleMsg("Connection Error", 5000); return; }
|
||||||
@ -4896,7 +4935,13 @@
|
|||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
if (files != null) { connectFiles(); } // Disconnect
|
if (files != null) { connectFiles(); } // Disconnect
|
||||||
} else {
|
} else {
|
||||||
|
if (Q('dp2authmethod').value == 1) {
|
||||||
files.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked }));
|
files.socket.send(JSON.stringify({ action: 'sshauth', username: Q('dp2user').value, password: Q('dp2pass').value, keep: Q('dp2keep').checked }));
|
||||||
|
} else {
|
||||||
|
var reader = new FileReader(), username = Q('dp2user').value, keypass = Q('dp2keypass').value, keep = Q('dp2keep').checked;
|
||||||
|
reader.onload = function (e) { files.socket.send(JSON.stringify({ action: 'sshauth', username: username, keypass: keypass, key: e.target.result, keep: keep })); }
|
||||||
|
reader.readAsText(Q('dp2key').files[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8946,9 +8946,7 @@
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tunnelUpdate(data) {
|
function tunnelUpdate(data) { if (typeof data == 'string') { xterm.writeUtf8(data); } else { xterm.writeUtf8(new Uint8Array(data)); } }
|
||||||
if (typeof data == 'string') { xterm.writeUtf8(data); } else { xterm.writeUtf8(new Uint8Array(data)); }
|
|
||||||
}
|
|
||||||
|
|
||||||
function sshTunnelUpdate(data) {
|
function sshTunnelUpdate(data) {
|
||||||
if (typeof data == 'string') {
|
if (typeof data == 'string') {
|
||||||
@ -8962,7 +8960,7 @@
|
|||||||
x += '<div id=d2passauth>';
|
x += '<div id=d2passauth>';
|
||||||
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
x += addHtmlValue("Password", '<input type=password id=dp2pass style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
x += '</div><div id=d2keyauth style=display:none>';
|
x += '</div><div id=d2keyauth style=display:none>';
|
||||||
x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:230px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />');
|
x += addHtmlValue("Key File", '<input type=file id=dp2key style=width:230px maxlength=64 autocomplete=off onchange=sshAuthUpdate(event) />' + '<div style=font-size:x-small>' + "Key file must be in OpenSSH format." + '</div>');
|
||||||
x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
x += addHtmlValue("Key Password", '<input type=password id=dp2keypass style=width:230px maxlength=64 autocomplete=off onkeyup=sshAuthUpdate(event) />');
|
||||||
x += '</div>';
|
x += '</div>';
|
||||||
x += addHtmlValue('', '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>');
|
x += addHtmlValue('', '<label><input id=dp2keep type=checkbox>' + "Remember credentials" + '</label>');
|
||||||
|
Loading…
Reference in New Issue
Block a user