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

Naming convention: key vs privateKey #1413

Closed
BarakBinyamin opened this issue Aug 7, 2024 · 1 comment
Closed

Naming convention: key vs privateKey #1413

BarakBinyamin opened this issue Aug 7, 2024 · 1 comment
Labels

Comments

@BarakBinyamin
Copy link

I'm having some difficulty shifting from connect to AuthHandler when using the client module

I used the type definitions from @types/ssh2 to help me through, idk how that's automatically downloaded when I install ssh2 but thats cool...

A ConnectConfig has privateKey field.
A PublicKeyAuthMethod has key field.

Are they both private keys or is one supposed to be a public key?

Here's my code for reference:

const Client   = require("ssh2").Client       
const sshClient = new Client()
sshClient.connect({
  host        :  myServer,
  port        :  22,
  username    : "milo",
  authHandler : function(methodsLeft, partialSuccess, doNextAuth){
    let  authConfig={
        type      : "publickey",
        host      : myServer,
        username  : "milo",     
        key       : key
      }
    doNextAuth(authConfig)
  }
})

vs

const Client   = require("ssh2").Client       
const sshClient = new Client()
 sshClient.connect({
    type           : "publickey",
    host           : myServer,
    username       : "milo",     
    privateKey     : key        // privateKey ~/.ssh/id_rsa in plaintext
})

Thanks!

@mscdex
Copy link
Owner

mscdex commented Aug 8, 2024

The documentation in the README states about the key property:

Can be a string, Buffer, or parsed key containing a private key

@mscdex mscdex closed this as completed Aug 8, 2024
@mscdex mscdex added the question label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants