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

ssh2 is not able to sign with private key #4487

Open
jkbz64 opened this issue Sep 4, 2023 · 5 comments
Open

ssh2 is not able to sign with private key #4487

jkbz64 opened this issue Sep 4, 2023 · 5 comments
Labels
assertion failed Crashes in a build with assertions enabled bug Something isn't working node.js Compatibility with Node.js APIs

Comments

@jkbz64
Copy link

jkbz64 commented Sep 4, 2023

What version of Bun is running?

0.8.1

What platform is your computer?

Linux 6.4.0-asahi-10-1-edge-ARCH aarch64 unknown

What steps can reproduce the bug?

import { readFileSync } from "node:fs";
import { Client } from "ssh2";

const connection = new Client();
connection
  .on("ready", () => {
    console.log("Client :: ready");
  })
  .connect({
    host: "<host>",
    port: 22,
    username: "<user>",
    privateKey: readFileSync("<path to pkey>"),
  });

What is the expected behavior?

Should output Client :: ready

What do you see instead?

8797 |   }
8798 | }), require_sign = __commonJS({
8799 |   "node_modules/browserify-sign/browser/sign.js"(exports, module) {
8800 |     var Buffer2 = require_safe_buffer().Buffer, createHmac = require_browser3(), crt = require_browserify_rsa(), EC = require_elliptic().ec, BN = require_bn3(), parseKeys = require_parse_asn1(), curves = require_curves2();
8801 | 
8802 |     function sign(hash, key, hashType, signType, tag) {
                                     ^
error: Error signing data with key: wrong private key type
      at sign (node:crypto:8802:34)
      at node:crypto:8944:74
      at sign (/tmp/ssh2/node_modules/ssh2/lib/protocol/keyParser.js:393:15)
      at /tmp/ssh2/node_modules/ssh2/lib/client.js:467:32
      at authPK (/tmp/ssh2/node_modules/ssh2/lib/protocol/Protocol.js:692:4)
      at USERAUTH_PK_OK (/tmp/ssh2/node_modules/ssh2/lib/client.js:466:12)
      at 60 (/tmp/ssh2/node_modules/ssh2/lib/protocol/handlers.misc.js:504:19)
      at onPayload (/tmp/ssh2/node_modules/ssh2/lib/protocol/Protocol.js:2052:9)
      at decrypt (/tmp/ssh2/node_modules/ssh2/lib/protocol/crypto.js:987:20)
      at parsePacket (/tmp/ssh2/node_modules/ssh2/lib/protocol/Protocol.js:2021:9)

Additional information

The same exact code works on node, tried to use Bun.file API instead of readFileSync, same result. Used standard ssh-keygen ssh-rsa key without password.

@jkbz64 jkbz64 added the bug Something isn't working label Sep 4, 2023
@FrancescoMasaia
Copy link

We replicated the same error in 1.0.4 version too

@Electroid Electroid added the node.js Compatibility with Node.js APIs label Oct 27, 2023
@jawaad-juggle
Copy link

Hey, I've run into this issue too. Did you managed to work a way around this?

@FrancescoMasaia
Copy link

FrancescoMasaia commented Nov 1, 2023 via email

@osbre
Copy link

osbre commented Aug 10, 2024

Duplicate of #4290 ?

Tried to run this example:

❯❯❯ BUN_JSC_dumpModuleLoadingState=1 bun run app.js                                                        ✘ 134
Loader [fetch] bun:main
loader [parsing] bun:main
Loader [resolve] /Users/user/code/bun-ssh-project/app.js
Loader [fetch] /Users/user/code/bun-ssh-project/app.js
loader [parsing] /Users/user/code/bun-ssh-project/app.js
Loader [resolve] fs
Loader [resolve] ssh2
Loader [fetch] fs
Loader [fetch] /Users/user/code/bun-ssh-project/node_modules/ssh2/lib/index.js
loader [parsing] fs
loader [parsing] string_decoder
Loader [link] string_decoder
Loader [evaluate] string_decoder
loader [parsing] util/types
Loader [link] util/types
Loader [evaluate] util/types
loader [parsing] /Users/user/code/bun-ssh-project/node_modules/ssh2/lib/index.js
loader [parsing] buffer
Loader [link] buffer
Loader [evaluate] buffer
dyld[27404]: missing symbol called
fish: Job 1, 'BUN_JSC_dumpModuleLoadingState=…' terminated by signal SIGABRT (Abort)

@nektro nektro added the assertion failed Crashes in a build with assertions enabled label Oct 22, 2024
@nektro
Copy link
Member

nektro commented Oct 22, 2024

in a debug build:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failed Crashes in a build with assertions enabled bug Something isn't working node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

6 participants