Merge remote-tracking branch 'origin' into feature/dropfile_improvements

This commit is contained in:
Nathan Byrd 2023-10-15 18:41:54 +00:00
commit e6cc890338
17 changed files with 975 additions and 857 deletions

View File

@ -7,7 +7,7 @@
"features": { "features": {
"ghcr.io/devcontainers/features/python:1": { "ghcr.io/devcontainers/features/python:1": {
"installTools": true, "installTools": true,
"version": "latest" "version": "3.11"
}, },
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {}, "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/jungaretti/features/ripgrep:1": {}, "ghcr.io/jungaretti/features/ripgrep:1": {},

2
.gitignore vendored
View File

@ -11,3 +11,5 @@ mail/
node_modules/ node_modules/
docs/_site/ docs/_site/
docs/.sass-cache/ docs/.sass-cache/
docs/.jekyll-cache/

17
.vscode/launch.json vendored
View File

@ -1,17 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/main.js"
}
]
}

View File

@ -35,6 +35,10 @@ npm install # or simply 'yarn'
## 0.0.13-beta to 0.0.14-beta ## 0.0.13-beta to 0.0.14-beta
* Due to changes to supported algorithms in newer versions of openssl, the default list of supported algorithms for the ssh login server has changed. There are both removed ciphers as well as optional new kex algorithms available now. ***NOTE:*** Changes to supported algorithms are only needed to support keys generated with new versions of openssl, if you already have a ssl key in use you should not have to make any changes to your config.
* Removed ciphers: 'blowfish-cbc', 'arcfour256', 'arcfour128', and 'cast128-cbc'
* Added kex: 'curve25519-sha256', 'curve25519-sha256@libssh.org', 'curve25519-sha256', 'curve25519-sha256@libssh.org', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521'
## 0.0.12-beta to 0.0.13-beta ## 0.0.12-beta to 0.0.13-beta
* To enable the new Waiting for Caller (WFC) support, please see [WFC](docs/modding/wfc.md). * To enable the new Waiting for Caller (WFC) support, please see [WFC](docs/modding/wfc.md).
* :exclamation: The SSH server's `ssh2` module has gone through a major upgrade. Existing users will need to comment out two SSH KEX algorithms from their `config.hjson` if present else clients such as NetRunner will not be able to connect over SSH. Comment out `diffie-hellman-group-exchange-sha256` and `diffie-hellman-group-exchange-sha1` * :exclamation: The SSH server's `ssh2` module has gone through a major upgrade. Existing users will need to comment out two SSH KEX algorithms from their `config.hjson` if present else clients such as NetRunner will not be able to connect over SSH. Comment out `diffie-hellman-group-exchange-sha256` and `diffie-hellman-group-exchange-sha1`

View File

@ -24,7 +24,7 @@ function ANSIEscapeParser(options) {
this.graphicRendition = {}; this.graphicRendition = {};
this.parseState = { this.parseState = {
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJKLmMsSTuUYZt@PXhlnpt]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
}; };
options = miscUtil.valueWithDefault(options, { options = miscUtil.valueWithDefault(options, {
@ -77,10 +77,25 @@ function ANSIEscapeParser(options) {
self.clearScreen = function () { self.clearScreen = function () {
self.column = 1; self.column = 1;
self.row = 1; self.row = 1;
self.positionUpdated();
self.emit('clear screen'); self.emit('clear screen');
}; };
self.positionUpdated = function () { self.positionUpdated = function () {
if(self.row > self.termHeight) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - self.termHeight;
}
self.emit('scroll', self.row - self.termHeight);
self.row = self.termHeight;
}
else if(self.row < 1) {
if(this.savedPosition) {
this.savedPosition.row -= self.row - 1;
}
self.emit('scroll', -(self.row - 1));
self.row = 1;
}
self.emit('position update', self.row, self.column); self.emit('position update', self.row, self.column);
}; };
@ -231,7 +246,7 @@ function ANSIEscapeParser(options) {
self.parseState = { self.parseState = {
// ignore anything past EOF marker, if any // ignore anything past EOF marker, if any
buffer: input.split(String.fromCharCode(0x1a), 1)[0], buffer: input.split(String.fromCharCode(0x1a), 1)[0],
re: /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsutEFGST])/g, // eslint-disable-line no-control-regex re: /(?:\x1b)(?:(?:\x5b([?=;0-9]*?)([ABCDEFGfHJKLmMsSTuUYZt@PXhlnpt]))|([78DEHM]))/g, // eslint-disable-line no-control-regex
stop: false, stop: false,
}; };
}; };
@ -271,9 +286,47 @@ function ANSIEscapeParser(options) {
opCode = match[2]; opCode = match[2];
args = match[1].split(';').map(v => parseInt(v, 10)); // convert to array of ints args = match[1].split(';').map(v => parseInt(v, 10)); // convert to array of ints
escape(opCode, args); // Handle the case where there is no bracket
if(!(_.isNil(match[3]))) {
opCode = match[3];
args = [];
// no bracket
switch(opCode) {
// save cursor position
case '7':
escape('s', args);
break;
// restore cursor position
case '8':
escape('u', args);
break;
// scroll up
case 'D':
escape('S', args);
break;
// move to next line
case 'E':
// functonality is the same as ESC [ E
escape(opCode, args);
break;
// create a tab at current cursor position
case 'H':
literal('\t');
break;
// scroll down
case 'M':
escape('T', args);
break;
}
}
else {
escape(opCode, args);
}
//self.emit('chunk', match[0]);
self.emit('control', match[0], opCode, args); self.emit('control', match[0], opCode, args);
} }
} while (0 !== re.lastIndex); } while (0 !== re.lastIndex);
@ -281,8 +334,8 @@ function ANSIEscapeParser(options) {
if (pos < buffer.length) { if (pos < buffer.length) {
var lastBit = buffer.slice(pos); var lastBit = buffer.slice(pos);
// :TODO: check for various ending LF's, not just DOS \r\n // handles either \r\n or \n
if ('\r\n' === lastBit.slice(-2).toString()) { if ('\n' === lastBit.slice(-1).toString()) {
switch (self.trailingLF) { switch (self.trailingLF) {
case 'default': case 'default':
// //
@ -290,14 +343,14 @@ function ANSIEscapeParser(options) {
// if we're going to end on termHeight // if we're going to end on termHeight
// //
if (this.termHeight === self.row) { if (this.termHeight === self.row) {
lastBit = lastBit.slice(0, -2); lastBit = lastBit.slice(0, -1);
} }
break; break;
case 'omit': case 'omit':
case 'no': case 'no':
case false: case false:
lastBit = lastBit.slice(0, -2); lastBit = lastBit.slice(0, -1);
break; break;
} }
} }
@ -308,48 +361,6 @@ function ANSIEscapeParser(options) {
self.emit('complete'); self.emit('complete');
}; };
/*
self.parse = function(buffer, savedRe) {
// :TODO: ensure this conforms to ANSI-BBS / CTerm / bansi.txt for movement/etc.
// :TODO: move this to "constants" section @ top
var re = /(?:\x1b\x5b)([\?=;0-9]*?)([ABCDHJKfhlmnpsu])/g;
var pos = 0;
var match;
var opCode;
var args;
// ignore anything past EOF marker, if any
buffer = buffer.split(String.fromCharCode(0x1a), 1)[0];
do {
pos = re.lastIndex;
match = re.exec(buffer);
if(null !== match) {
if(match.index > pos) {
parseMCI(buffer.slice(pos, match.index));
}
opCode = match[2];
args = getArgArray(match[1].split(';'));
escape(opCode, args);
self.emit('chunk', match[0]);
}
} while(0 !== re.lastIndex);
if(pos < buffer.length) {
parseMCI(buffer.slice(pos));
}
self.emit('complete');
};
*/
function escape(opCode, args) { function escape(opCode, args) {
let arg; let arg;
@ -382,6 +393,37 @@ function ANSIEscapeParser(options) {
self.moveCursor(-arg, 0); self.moveCursor(-arg, 0);
break; break;
// line feed
case 'E':
arg = isNaN(args[0]) ? 1 : args[0];
if(this.row + arg > this.termHeight) {
this.emit('scroll', arg - (this.termHeight - this.row));
self.moveCursor(0, this.termHeight);
}
else {
self.moveCursor(0, arg);
}
break;
// reverse line feed
case 'F':
arg = isNaN(args[0]) ? 1 : args[0];
if(this.row - arg < 1) {
this.emit('scroll', -(arg - this.row));
self.moveCursor(0, 1 - this.row);
}
else {
self.moveCursor(0, -arg);
}
break;
// absolute horizontal cursor position
case 'G':
arg = isNaN(args[0]) ? 1 : args[0];
self.column = Math.max(1, arg);
self.positionUpdated();
break;
case 'f': // horiz & vertical case 'f': // horiz & vertical
case 'H': // cursor position case 'H': // cursor position
//self.row = args[0] || 1; //self.row = args[0] || 1;
@ -392,14 +434,37 @@ function ANSIEscapeParser(options) {
self.positionUpdated(); self.positionUpdated();
break; break;
// save position
case 's': // erase display/screen
self.saveCursorPosition(); case 'J':
if(isNaN(args[0]) || 0 === args[0]) {
self.emit('erase rows', self.row, self.termHeight);
}
else if (1 === args[0]) {
self.emit('erase rows', 1, self.row);
}
else if (2 === args[0]) {
self.clearScreen();
}
break; break;
// restore position // erase text in line
case 'u': case 'K':
self.restoreCursorPosition(); if(isNaN(args[0]) || 0 === args[0]) {
self.emit('erase columns', self.row, self.column, self.termWidth);
}
else if (1 === args[0]) {
self.emit('erase columns', self.row, 1, self.column);
}
else if (2 === args[0]) {
self.emit('erase columns', self.row, 1, self.termWidth);
}
break;
// insert line
case 'L':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('insert line', self.row, arg);
break; break;
// set graphic rendition // set graphic rendition
@ -471,15 +536,52 @@ function ANSIEscapeParser(options) {
self.emit('sgr update', self.graphicRendition); self.emit('sgr update', self.graphicRendition);
break; // m break; // m
// :TODO: s, u, K // save position
case 's':
// erase display/screen self.saveCursorPosition();
case 'J':
// :TODO: Handle other 'J' types!
if (2 === args[0]) {
self.clearScreen();
}
break; break;
// Scroll up
case 'S':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('scroll', arg);
break;
// Scroll down
case 'T':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('scroll', -arg);
break;
// restore position
case 'u':
self.restoreCursorPosition();
break;
// clear
case 'U':
self.clearScreen();
break;
// delete line
// TODO: how should we handle 'M'?
case 'Y':
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('delete line', self.row, arg);
break;
// back tab
case 'Z':
// calculate previous tabstop
self.column = Math.max( 1, self.column - (self.column % 8 || 8) );
self.positionUpdated();
break;
case '@':
// insert column(s)
arg = isNaN(args[0]) ? 1 : args[0];
self.emit('insert columns', self.row, self.column, arg);
break;
} }
} }
} }

View File

@ -208,17 +208,17 @@ module.exports = class ArchiveUtil {
// pty.js doesn't currently give us a error when things fail, // pty.js doesn't currently give us a error when things fail,
// so we have this horrible, horrible hack: // so we have this horrible, horrible hack:
let err; let err;
proc.once('data', d => { proc.onData(d => {
if (_.isString(d) && d.startsWith('execvp(3) failed.')) { if (_.isString(d) && d.startsWith('execvp(3) failed.')) {
err = Errors.ExternalProcess(`${action} failed: ${d.trim()}`); err = Errors.ExternalProcess(`${action} failed: ${d.trim()}`);
} }
}); });
proc.once('exit', exitCode => { proc.onExit(exitEvent => {
return cb( return cb(
exitCode exitEvent.exitCode
? Errors.ExternalProcess( ? Errors.ExternalProcess(
`${action} failed with exit code: ${exitCode}` `${action} failed with exit code: ${exitEvent.exitCode}`
) )
: err : err
); );
@ -358,10 +358,10 @@ module.exports = class ArchiveUtil {
output += data; output += data;
}); });
proc.once('exit', exitCode => { proc.onExit(exitEvent => {
if (exitCode) { if (exitEvent.exitCode) {
return cb( return cb(
Errors.ExternalProcess(`List failed with exit code: ${exitCode}`) Errors.ExternalProcess(`List failed with exit code: ${exitEvent.exitCode}`)
); );
} }

View File

@ -316,6 +316,75 @@ function display(client, art, options, cb) {
} }
}); });
// Remove any MCI's that are in erased rows
ansiParser.on('erase row', (startRow, endRow) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] >= startRow && mciInfo.position[0] <= endRow) {
delete mciMap[mapKey];
}
});
});
// Remove any MCI's that are in erased columns
ansiParser.on('erase columns', (row, startCol, endCol) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (
mciInfo.position[0] === row &&
mciInfo.position[1] >= startCol &&
mciInfo.position[1] <= endCol
) {
delete mciMap[mapKey];
}
});
});
ansiParser.on('insert columns', (row, startCol, numCols) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] === row && mciInfo.position[1] >= startCol) {
mciInfo.position[1] += numCols;
if(mciInfo.position[1] > client.term.termWidth) {
delete mciMap[mapKey];
}
}
});
});
// Clear the screen, removing any MCI's
ansiParser.on('clear screen', () => {
_.forEach(mciMap, (mciInfo, mapKey) => {
delete mciMap[mapKey];
});
});
ansiParser.on('scroll', (scrollY) => {
_.forEach(mciMap, (mciInfo) => {
mciInfo.position[0] -= scrollY;
});
});
ansiParser.on('insert line', (row, numLines) => {
_.forEach(mciMap, (mciInfo) => {
if (mciInfo.position[0] >= row) {
mciInfo.position[0] += numLines;
}
});
});
ansiParser.on('delete line', (row, numLines) => {
_.forEach(mciMap, (mciInfo, mapKey) => {
if (mciInfo.position[0] >= row) {
if(mciInfo.position[0] < row + numLines) {
// unlike scrolling, the rows are actually gone,
// so we need to delete any MCI's that are in them
delete mciMap[mapKey];
}
else {
mciInfo.position[0] -= numLines;
}
}
});
});
ansiParser.on('literal', literal => client.term.write(literal, false)); ansiParser.on('literal', literal => client.term.write(literal, false));
ansiParser.on('control', control => client.term.rawWrite(control)); ansiParser.on('control', control => client.term.rawWrite(control));

View File

@ -188,22 +188,15 @@ module.exports = () => {
// //
// 1 - Generate a Private Key (PK): // 1 - Generate a Private Key (PK):
// Currently ENiGMA 1/2 requires a PKCS#1 PEM formatted PK. // Currently ENiGMA 1/2 requires a PKCS#1 PEM formatted PK.
// To generate a secure PK, issue the following command: // For information on generating a key, see:
// // https://nuskooler.github.io/enigma-bbs/servers/loginservers/ssh.html#generate-a-ssh-private-key
// > openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
// -pkeyopt rsa_keygen_pubexp:65537 | openssl rsa \
// -out ./config/security/ssh_private_key.pem -aes128
//
// (The above is a more modern equivalent of the following):
// > openssl genrsa -aes128 -out ./config/security/ssh_private_key.pem 2048
// //
// 2 - Set 'privateKeyPass' to the password you used in step #1 // 2 - Set 'privateKeyPass' to the password you used in step #1
// //
// 3 - Finally, set 'enabled' to 'true' // 3 - Finally, set 'enabled' to 'true'
// //
// Additional reading: // Additional reading:
// - https://blog.sleeplessbeastie.eu/2017/12/28/how-to-generate-private-key/ // - https://nuskooler.github.io/enigma-bbs/servers/loginservers/ssh.html
// - https://gist.github.com/briansmith/2ee42439923d8e65a266994d0f70180b
// //
privateKeyPem: paths.join( privateKeyPem: paths.join(
__dirname, __dirname,
@ -222,14 +215,18 @@ module.exports = () => {
// //
algorithms: { algorithms: {
kex: [ kex: [
'curve25519-sha256',
'curve25519-sha256@libssh.org',
'ecdh-sha2-nistp256', 'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384', 'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521', 'ecdh-sha2-nistp521',
'diffie-hellman-group14-sha1', 'diffie-hellman-group14-sha1',
'diffie-hellman-group1-sha1', 'diffie-hellman-group1-sha1',
// Group exchange not currnetly supported 'curve25519-sha256',
// 'diffie-hellman-group-exchange-sha256', 'curve25519-sha256@libssh.org',
// 'diffie-hellman-group-exchange-sha1', 'ecdh-sha2-nistp256',
'ecdh-sha2-nistp384',
'ecdh-sha2-nistp521',
], ],
cipher: [ cipher: [
'aes128-ctr', 'aes128-ctr',
@ -242,12 +239,7 @@ module.exports = () => {
'aes256-cbc', 'aes256-cbc',
'aes192-cbc', 'aes192-cbc',
'aes128-cbc', 'aes128-cbc',
'blowfish-cbc',
'3des-cbc', '3des-cbc',
'arcfour256',
'arcfour128',
'cast128-cbc',
'arcfour',
], ],
hmac: [ hmac: [
'hmac-sha2-256', 'hmac-sha2-256',

View File

@ -115,9 +115,10 @@ module.exports = class Door {
spawnOptions spawnOptions
); );
prePty.once('exit', exitCode => { prePty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info( this.client.log.info(
{ exitCode: exitCode }, { exitCode, signal },
'Door pre-command exited' 'Door pre-command exited'
); );
return callback(null); return callback(null);
@ -167,7 +168,7 @@ module.exports = class Door {
this.doorPty.onData(this.doorDataHandler.bind(this)); this.doorPty.onData(this.doorDataHandler.bind(this));
this.doorPty.once('close', () => { this.doorPty.onExit( (/*exitEvent*/) => {
return this.restoreIo(this.doorPty); return this.restoreIo(this.doorPty);
}); });
} else if ('socket' === this.io) { } else if ('socket' === this.io) {
@ -180,8 +181,9 @@ module.exports = class Door {
); );
} }
this.doorPty.once('exit', exitCode => { this.doorPty.onExit(exitEvent => {
this.client.log.info({ exitCode: exitCode }, 'Door exited'); const {exitCode, signal} = exitEvent;
this.client.log.info({ exitCode, signal }, 'Door exited');
if (this.sockServer) { if (this.sockServer) {
this.sockServer.close(); this.sockServer.close();

View File

@ -167,17 +167,17 @@ class ScheduledEvent {
return cb(e); return cb(e);
} }
proc.once('exit', exitCode => { proc.onExit(exitEvent => {
if (exitCode) { if (exitEvent.exitCode) {
Log.warn( Log.warn(
{ eventName: this.name, action: this.action, exitCode: exitCode }, { eventName: this.name, action: this.action, exitCode: exitEvent.exitCode },
'Bad exit code while performing scheduled event action' 'Bad exit code while performing scheduled event action'
); );
} }
return cb( return cb(
exitCode exitEvent.exitCode
? Errors.ExternalProcess( ? Errors.ExternalProcess(
`Bad exit code while performing scheduled event action: ${exitCode}` `Bad exit code while performing scheduled event action: ${exitEvent.exitCode}`
) )
: null : null
); );

View File

@ -485,13 +485,10 @@ exports.getModule = class TransferFileModule extends MenuModule {
} }
}); });
externalProc.once('close', () => { externalProc.onExit(exitEvent => {
return this.restorePipeAfterExternalProc(); const {exitCode, signal} = exitEvent;
});
externalProc.once('exit', exitCode => {
this.client.log.debug( this.client.log.debug(
{ cmd: cmd, args: args, exitCode: exitCode }, { cmd: cmd, args: args, exitCode, signal },
'Process exited' 'Process exited'
); );

View File

@ -77,6 +77,8 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0) mercenary (0.4.0)
minitest (5.19.0) minitest (5.19.0)
nokogiri (1.15.4-aarch64-linux)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux) nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
pathutil (0.16.2) pathutil (0.16.2)
@ -101,6 +103,7 @@ GEM
webrick (1.8.1) webrick (1.8.1)
PLATFORMS PLATFORMS
aarch64-linux
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES

View File

@ -131,4 +131,5 @@ collections:
- admin/oputil.md - admin/oputil.md
- admin/updating.md - admin/updating.md
- troubleshooting/monitoring-logs.md - troubleshooting/monitoring-logs.md
- troubleshooting/ssh-troubleshooting.md

View File

@ -3,9 +3,13 @@ layout: page
title: SSH Server title: SSH Server
--- ---
## SSH Login Server ## SSH Login Server
The ENiGMA½ SSH *login server* allows secure user logins over SSH (ssh://). The ENiGMA½ SSH *login server* allows secure user logins over SSH (ssh://).
*Note:* If you run into any troubles during SSH setup, please see [Troubleshooting SSH](../../troubleshooting/ssh-troubleshooting.md)
## Configuration ## Configuration
Entries available under `config.loginServers.ssh`: Entries available under `config.loginServers.ssh`:
| Item | Required | Description | | Item | Required | Description |
@ -20,10 +24,8 @@ Entries available under `config.loginServers.ssh`:
| `algorithms` | :-1: | Configuration block for SSH algorithms. Includes keys of `kex`, `cipher`, `hmac`, and `compress`. See the algorithms section in the [ssh2-streams](https://github.com/mscdex/ssh2-streams#ssh2stream-methods) documentation for details. For defaults set by ENiGMA½, see `core/config_default.js`. | `algorithms` | :-1: | Configuration block for SSH algorithms. Includes keys of `kex`, `cipher`, `hmac`, and `compress`. See the algorithms section in the [ssh2-streams](https://github.com/mscdex/ssh2-streams#ssh2stream-methods) documentation for details. For defaults set by ENiGMA½, see `core/config_default.js`.
| `traceConnections` | :-1: | Set to `true` to enable full trace-level information on SSH connections. | `traceConnections` | :-1: | Set to `true` to enable full trace-level information on SSH connections.
* *IMPORTANT* With the `privateKeyPass` option set, make sure that you verify that the config file is not readable by other users! * *IMPORTANT* With the `privateKeyPass` option set, make sure that you verify that the config file is not readable by other users!
### Example Configuration ### Example Configuration
```hjson ```hjson
@ -40,42 +42,93 @@ Entries available under `config.loginServers.ssh`:
``` ```
## Generate a SSH Private Key ## Generate a SSH Private Key
To utilize the SSH server, an SSH Private Key (PK) will need generated. OpenSSH or (with some versions) OpenSSL can be used for this task: To utilize the SSH server, an SSH Private Key (PK) will need generated. OpenSSH or (with some versions) OpenSSL can be used for this task:
### OpenSSH ### OpenSSH (Preferred)
```bash #### OpenSSH Install - Linux / Mac
ssh-keygen -m PEM -h -f config/ssh_private_key.pem
If it is not already available, install OpenSSH using the package manager of your choice (should be pre-installed on most distributions.)
#### Running OpenSSH - Linux / Mac
From the root directory of the Enigma BBS, run the following:
```shell
mkdir -p config/security
ssh-keygen -t rsa -m PEM -h -f config/security/ssh_private_key.pem
``` ```
#### Windows Install - OpenSSH
OpenSSH may already be installed, try running `ssh-keygen.exe`. If not, see this page: [Install OpenSSH for Windows](https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=gui)
#### Running OpenSSH - Windows
After installation, go to the root directory of your enigma project and run:
```powershell
mkdir .\config\security -ErrorAction SilentlyContinue
ssh-keygen.exe -t rsa -m PEM -h -f .\config\security\ssh_private_key.pem
```
#### ssh-keygen options
Option descriptions: Option descriptions:
| Option | Description | | Option | Description |
|------|-------------| |------|-------------|
| `-t rsa` | Use the RSA algorithm needed for the `ssh2` library |
| `-m PEM` | Set the output format to `PEM`, compatible with the `ssh2` library | | `-m PEM` | Set the output format to `PEM`, compatible with the `ssh2` library |
| `-h` | Generate a host key | | `-h` | Generate a host key |
| `-f config/ssh_private_key.pem` | Filename for the private key. Used in the `privateKeyPem` option in the configuration | | `-f config/ssh_private_key.pem` | Filename for the private key. Used in the `privateKeyPem` option in the configuration |
When you execute the `ssh-keygen` command it will ask for a passphrase (and a confirmation.) This should then be used as the value for `privateKeyPass` in the configuration. When you execute the `ssh-keygen` command it will ask for a passphrase (and a confirmation.) This should then be used as the value for `privateKeyPass` in the configuration.
### OpenSSL ### OpenSSL
If you do not have OpenSSH installed or if you have trouble with the above OpenSSH commands, using some versions for OpenSSL (before version 3) the following commands may work as well: #### Open SSL Install - Linux / Mac
If not already installed, install via the `openssl` package on most package managers.
```bash #### Open SSL Install - Windows
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 | openssl rsa -out ./config/ssh_private_key.pem -aes128
```powershell
winget install -e --id ShiningLight.OpenSSL
``` ```
Or for even older OpenSSL versions: #### Running OpenSSL
```bash *Note:* Using `ssh-keygen` from OpenSSL is recommended where possible. If you have trouble with the above OpenSSH commands, using some versions for OpenSSL (before version 3) the following commands may work as well:
#### Running OpenSSL - Linux / Mac
Run the following from the root directory of Enigma
```shell
mkdir -p config/security
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 | openssl rsa -out ./config/security/ssh_private_key.pem -aes128
```
#### Running OpenSSL - Windows
Run the following from the root directory of Enigma (note: you may need to specify the full path to openssl.exe if it isn't in your system path, on my system it was `C:\Program Files\OpenSSL-Win64\bin\openssl.exe`):
```powershell
mkdir .\config\security -ErrorAction SilentlyContinue
openssl.exe genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 | openssl.exe rsa -out ./config/security/ssh_private_key.pem -aes128
```
#### Running Older OpenSSL
For older OpenSSL versions, the following command has been known to work:
```shell
openssl genrsa -aes128 -out ./config/ssh_private_key.pem 2048 openssl genrsa -aes128 -out ./config/ssh_private_key.pem 2048
``` ```
Note that you may need `-3des` for very old implementations or SSH clients! *Note:* that you may need `-3des` for very old implementations or SSH clients!
## Prompt ## Prompt

View File

@ -0,0 +1,45 @@
---
layout: page
title: Troubleshooting SSH
---
Stuck with errors trying to get your SSH setup configured? See below for some common problems. Or as always, reach out to us by creating an [Issue](https://github.com/NuSkooler/enigma-bbs/issues) or start a [Discussion](https://github.com/NuSkooler/enigma-bbs/discussions)
## No Such File or Directory
***Symptom:***
BBS not starting with an error similar to the following:
```shell
Error initializing: Error: ENOENT: no such file or directory, open '<path>/config/security/ssh_private_key.pem'
```
***Solution:***
Several things can cause this:
1. `ssh_private_key.pem` was installed to the wrong location. Make sure that it is in the `config/security` directory and has the name matching the error message. You can also change your `config.hjson` if you prefer to point to the location of the key file.
2. `ssh_private_key.pem` has the wrong file permissions. Verify that the file will be readable by the user that the BBS is running as. Because it is a cryptographic key however, we do recommend that access is restricted only to that user.
## Error With Netrunner
***Symptom:***
Some ssh clients connect, but Netrunner (and other older clients) get a connection failed message and the following is in the log:
```shell
"level":40,"error":"Handshake failed","code":2,"msg":"SSH connection error"
```
***Solution:***
The key was most likely not generated with the `-t rsa` option, and is using a newer algorithm that is not supported by Netrunner and similar clients. Regenerate the certificate with the `-t rsa` option.
***Symptom:***
Some ssh clients connect, but Netrunner (and other older clients) get a connection failed message and the following is in the log:
```shell
"level":40,"error":"Group exchange not implemented for server","msg":"SSH connection error"
```
***Solution:***
Remove the following encryption protocols from your `config.hjson`: `diffie-hellman-group-exchange-sha256` and `diffie-hellman-group-exchange-sha1`

View File

@ -50,7 +50,7 @@
"minimist": "^1.2.6", "minimist": "^1.2.6",
"moment": "2.29.4", "moment": "2.29.4",
"nntp-server": "3.1.0", "nntp-server": "3.1.0",
"node-pty": "0.10.1", "node-pty": "1.0.0",
"nodemailer": "6.7.7", "nodemailer": "6.7.7",
"otplib": "11.0.1", "otplib": "11.0.1",
"qrcode-generator": "^1.4.4", "qrcode-generator": "^1.4.4",
@ -59,7 +59,7 @@
"sanitize-filename": "^1.6.3", "sanitize-filename": "^1.6.3",
"sqlite3": "5.1.6", "sqlite3": "5.1.6",
"sqlite3-trans": "1.3.0", "sqlite3-trans": "1.3.0",
"ssh2": "1.11.0", "ssh2": "1.14.0",
"systeminformation": "5.21.7", "systeminformation": "5.21.7",
"telnet-socket": "0.2.4", "telnet-socket": "0.2.4",
"temptmp": "^1.1.0", "temptmp": "^1.1.0",

1299
yarn.lock

File diff suppressed because it is too large Load Diff