Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
voipmeister opened this issue Sep 1, 2024 · 2 comments
Open
2 tasks done

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

voipmeister opened this issue Sep 1, 2024 · 2 comments

Comments

@voipmeister
Copy link
Contributor

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

  • Generate an SSH key with the command from the docs (config.hjson comments):
    openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \
                    -pkeyopt rsa_keygen_pubexp:65537 | openssl rsa \
                    -out ./config/security/ssh_private_key.pem -aes128
    
  • Set enabled: true in the section SSH
  • Start Enigma with ./main.js

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

  • I am using Node.js v14.x LTS or higher
  • npm install or yarn reports success
  • Actual Node.js version (node --version): v18.20.4
  • Operating system (uname -a on *nix systems): Linux docker01 6.1.0-23-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 GNU/Linux (this isn't a docker container despite hostname)
  • Revision (git rev-parse --short HEAD): 5e720457
  • Any additional relevant information about your setup: none
@voipmeister
Copy link
Contributor Author

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
Copy link
Contributor Author

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 #566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant