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

privateKey: Buffer.from('...') #446

Open
YanDevDe opened this issue Sep 24, 2022 · 4 comments
Open

privateKey: Buffer.from('...') #446

YanDevDe opened this issue Sep 24, 2022 · 4 comments
Labels

Comments

@YanDevDe
Copy link

README.md shows privateKey: Buffer.from('...'), but I assume the privateKey expects only string, or not?
Would fix this typo to avoid confusion as setting Buffer in privateKey actually won't work.

@eyal-solomon1
Copy link

@YanDevDe facing the same issue .. what did work for you ?

@YanDevDe
Copy link
Author

Convert the Buffer to string:

privateKey: buffer.toString(“utf8”)

Make sure that the key is in PEM format (if not, you may need to convert it)

@ecker00
Copy link

ecker00 commented Dec 20, 2022

Would think that reading the file as UTF-8 would work, but I get:

const privateKey = await fs.readFile(env.SSH_privateKey, 'utf-8');
// Error: ENOENT: no such file or directory, stat '-----BEGIN OPENSSH PRIVATE KEY----- …

I also get errors when I try to use the privateKeyPath approach:

const privateKeyPath = '/myPathTo/id_ed25519';
// TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined

So not figured out how to get this to work, and had to downgrade to 12.05 for now.

EDIT: Turns out my first approach worked, also what steelbrain suggested bellow, but I had some error checks in my own client that was the issue.

@steelbrain
Copy link
Owner

@ecker00 I think you're trying to read the private key (which is already the key itself, not a path) as a path from the filesystem.

In your case, you may be able to get away with just replacing with the following code:

const privateKey = Buffer.from(env.SSH_privateKey, 'utf-8')

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

4 participants