NuSkooler / enigma-bbs

ENiGMA½ BBS Software
https://nuskooler.github.io/enigma-bbs/
BSD 2-Clause "Simplified" License
546 stars 104 forks source link

Default Debian 12 installation doesn't support SSH key format #563

Open voipmeister opened 2 months ago

voipmeister commented 2 months ago

Describe the Bug On Debian 12 (Bookworm) and a default install, the command to generate an SSH key (the one from the docs) generates an unsupported key, which can not be used when SSH is enabled.

To Reproduce

Expected Behavior Enigma is started with SSH support.

Actual Behavior When starting Enigma, the following error is observed:

./main.js
Error initializing: Error: Cannot parse privateKey: Unsupported key format
    at new Server (/home/enigma/enigma-bbs/node_modules/ssh2/lib/server.js:249:15)
    at SSHServerModule.createServer (/home/enigma/enigma-bbs/core/servers/login/ssh.js:396:23)
    at /home/enigma/enigma-bbs/core/listening_server.js:39:36
    at /home/enigma/enigma-bbs/core/module_util.js:120:28
    at loaded (/home/enigma/enigma-bbs/core/module_util.js:93:20)
    at loadModuleEx (/home/enigma/enigma-bbs/core/module_util.js:76:12)
    at loadModule (/home/enigma/enigma-bbs/core/module_util.js:90:5)
    at /home/enigma/enigma-bbs/core/module_util.js:111:17
    at /home/enigma/enigma-bbs/node_modules/async/dist/async.js:2588:44
    at eachOfArrayLike (/home/enigma/enigma-bbs/node_modules/async/dist/async.js:506:13)
Error initializing: Error: Cannot parse privateKey: Unsupported key format
    at new Server (/home/enigma/enigma-bbs/node_modules/ssh2/lib/server.js:249:15)
    at SSHServerModule.createServer (/home/enigma/enigma-bbs/core/servers/login/ssh.js:396:23)
    at /home/enigma/enigma-bbs/core/listening_server.js:39:36
    at /home/enigma/enigma-bbs/core/module_util.js:120:28
    at loaded (/home/enigma/enigma-bbs/core/module_util.js:93:20)
    at loadModuleEx (/home/enigma/enigma-bbs/core/module_util.js:76:12)
    at loadModule (/home/enigma/enigma-bbs/core/module_util.js:90:5)
    at /home/enigma/enigma-bbs/core/module_util.js:111:17
    at /home/enigma/enigma-bbs/node_modules/async/dist/async.js:2588:44
    at eachOfArrayLike (/home/enigma/enigma-bbs/node_modules/async/dist/async.js:506:13)

Screenshots Not applicable.

Environment

voipmeister commented 2 months ago

Verifying the key does seem to work:

~/enigma-bbs$ openssl rsa -in ./config/security/ssh_private_key.pem -check
Enter pass phrase for ./config/security/ssh_private_key.pem:
RSA key ok
writing RSA key
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCx27AJDuYtbfd6
cYuZu0I+1BNYcOcRrdvHe+EFABpo1XSv1aebjfe19gQ82eLZEvhGIgde0zATFoZW
P0vmTG7cVBUMJ4YFiQKYEyAZGktqllVaC+6BIkHbDEOgMuc5fvCJYrVYTQqas3Np
Cq42h4U1futfdG143ZHXKLLtl5oqO+F5z8krNJ9eZrHsioU+Rg9TzCQW4Lmbn73u
RfFo5zKBspguRdXY+hb94+khzGVajfs8nFboIAw56v2u/yt3kWCOMy6SOXXlNw8G
cfyQuXEJIpv/+I1bKLbBIp0BxTlv1E7iuKupJPB8BYV4m3/4ra7sm0WTxNzWBHsf
xgtQ967/AgMBAAECggEAO33qDKWcra5+XMkVMod2GbDzhZ5CVGIMxVW1B2io7M8V
mGlFhp0+sfFIKpiRLh4PyNnCEGBg0Mm0hq3mc/K2FGHVpnqj9D8HjJm9H1hxyIXf
p96c2Tn9wEkCZ9gPCubgi3vmf9JJTUTgQk8NxfSfxKyfC49UvNyUV11oOFwA98X/
rVil+7vFbIRCQ6D9rkVz/5tPu9NGD6xxFGT5n0JQkh44Aricf4oVOqRz4HEAYWiz
...
-----END PRIVATE KEY-----
voipmeister commented 2 months ago

The solution for this issue is to convert the key to a supported format, like so:

openssl rsa -in unsupported.key -out supported.key -traditional

This is now document in both the configuration template + docs, via https://github.com/NuSkooler/enigma-bbs/pull/566