Issue with SSH - GitHub and BitBucket
See original GitHub issueSystem information
- node version: v10.14.1
- npm version: 6.4.1
- OS/version/architecture: Windows 10
- Applicable nodegit version: 0.23.0
I am able to run the unit test for ssh clone:
it("can clone with ssh while manually loading an encrypted key", function() {
var test = this;
var url = "git@github.com:nodegit/test.git";
var opts = {
fetchOpts: {
callbacks: {
certificateCheck: function() {
return 1;
},
credentials: function(url, userName) {
return NodeGit.Cred.sshKeyNew(
userName,
sshEncryptedPublicKeyPath,
sshEncryptedPrivateKeyPath,
"test-password"
);
}
}
}
};
return Clone(url, clonePath, opts).then(function(repo) {
assert.ok(repo instanceof Repository);
test.repository = repo;
});
});
However, when I attempt using any new SSH key I generate either in Bitbucket or Github, I am getting the following error: Failed to authenticate SSH session: Unable to send userauth-publickey request
Is there any guidance on what I may have done wrong?
Here is my code:
const cloneURL: string = "git@github.com:repo/project.git";
let publickey: string = "path/to/pubKey";
let privatekey: string = "path/to/privKey";
let passphrase: string = "testpw";
let localPath: string = "path/to/repo";
var opts = {
fetchOpts: {
callbacks: {
certificateCheck: function() {
return 1;
},
credentials: function(url, userName) {
return nodegit.Cred.sshKeyNew(
userName,
publickey,
privatekey,
passphrase
);
}
}
}
};
nodegit.Clone.clone(cloneURL, localPath, opts).then(function(repo) {
if(repo instanceof nodegit.Repository) {
console.log("Good!");
}
else {
console.log("Bad!");
}
}).catch((reason) => {
console.log(reason);
});
Is this a patch issue or maybe how I am generating my key?? It works fine with regular git clone (I am supplying GIT_SSH_COMMAND in order to point to the right key location).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Troubleshooting SSH issues | Bitbucket Cloud Cloud KB
Bitbucket Cloud complains "Network is down" and cannot operate commands via ssh · Invalid SSH Key · Multiple SSH Keys settings for different ......
Read more >Add SSH key for both github and bitbucket in single PC
Complete Guide to Add SSH keys for both github and bitbucket in single PC. if you already have one ssh key then you...
Read more >Setting up a seperate Github and Bitbucket account
Git is set up for a single github user using https, not ssh; There is only a known_hosts file in ~/.ssh/ ... Obviously...
Read more >Unable to deploy from Bitbucket using SSH Key #606 - GitHub
If this works, we know that the problem is something with your specific case perhaps the fact that you have a custom port....
Read more >Open PR doesn't work with BitBucket and custom SSH ...
Describe the bug BitBucket allows to use a different SSH username than the traditional git (i.e. my-username@bitbucket.org instead of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Moved credentials outside of options as suggested by @ambrosejed, however, now getting:
Node v11.10.0
nodegit 0.23.1
Got the same problem here, solved by checking my ‘private key’ : Wrong format.
You need to export your private key to OpenSSH key
Should look like this : https://github.com/nodegit/nodegit/blob/master/test/encrypted_rsa
And the code used is that one :