godotengine / godot-git-plugin

Git implementation of the VCS interface in Godot
MIT License
656 stars 64 forks source link

Error -1: failed to set credentials: The parameter is incorrect. #230

Open NickMakesGames opened 3 months ago

NickMakesGames commented 3 months ago

Hi all! I just installed this plugin to a project that is already using git and is configured to push/pull with GitHub. Previously I had been using VSCode as my Git Client, but I'm trying to move more of my workflow directly into the Godot editor. I was able to make a few small commits with the plugin, and I added my id_rsa files to the VCS settings panel:

image

but when I try to push, I get this error message:

 *  core/variant/variant_utility.cpp:1091 - GitPlugin: Could not connect to remote "origin". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password. Error -1: failed to set credentials: The parameter is incorrect.
 * in godot-git-plugin\src\git_plugin.cpp:GitPlugin::_push#L532

Wondering if anybody has tips for troubleshooting? I'm not sure what a PAT token is or how to generate one. I'm open to trying that, but I'd also love to try and understand why this isn't working out-of-the-box

Calinou commented 3 months ago

Does your SSH key use ECDSA (elliptic curve cryptography)? These are currently not supported: https://github.com/godotengine/godot-git-plugin/issues/193

I'm not sure what a PAT token is or how to generate one

A PAT is a Personal Access Token. You can create it from your GitHub account settings: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

markeel commented 3 months ago

Did you include the passphrase for your SSH key? It sounded similar to #172 but that should have been fixed in the 3.1 (12/2023) release of the plugin, even though the issue still says open. Basically if you can issue the git fetch command from the command line and the access through SSH works, the Godot Editor should work be specifying the same SSH key. When you were using it under VS Code was it the same SSH key? You need to tell GitHub about your SSH keys if it is a different key. Since I don't use VSCode I can't provide the best insight.

NickMakesGames commented 3 months ago

I checked my private and public keys. The private key has the header:

-----BEGIN OPENSSH PRIVATE KEY-----

which would suggest that it does not use ECDSA. I followed this StackOverflow article to check if the private key has a passphrase ( https://security.stackexchange.com/questions/129724/how-to-check-if-an-ssh-private-key-has-passphrase-or-not ). My key does not have a passphrase. I don't set up GitHub access tokens very often, but I don't think I've ever needed to include a passphrase before. Is that not the case here?

markeel commented 3 months ago

Just FYI - I took some time and tried to reproduce this on a Windows system (I normally use Linux). I set up a fresh Git instance https://git-scm.com/download/win, used ssh-keygen -t rsa, and then used the GitHub Keys page (https://github.com/settings/keys) to add the public key I had just created. I cloned a github project I had and then made a minor change and tried to push it using the Godot 4.2.1 and Git Plugin 4.1+ from asset library. It got a similar but not identical error.

GitPlugin: Could not connect to remote "origin". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password. Error -16: Failed to retrieve list of SSH authentication methods: Failed getting response in godot-git-plugin\src\git_plugin.cpp:GitPlugin::_pull#L435

Pushing from the Git Bash window worked fine.

I'll try to build from source and see I can understand why it's getting this error.

markeel commented 3 months ago

Ok - that took way too long for me to figure out. The problem is that -----BEGIN OPENSSH PRIVATE KEY----- is not supported by the libssh2 library that was used by libgit2 which is used by this plugin. I haven't figured out why, but it clearly is the root cause.

You can workaround this issue by doing:

ssh-keygen -t rsa -m PEM

This will then generate a id_rsa file with a header of -----BEGIN RSA PRIVATE KEY----- which will work.

Notice the OPENSSH vs. RSA.

In the process of me trying to get better trace messages, I manually used the latest libssh2 built with the latest openssl, and a test program that does a connect and it worked, so maybe the key is to use a later version of libssh2. That will have to be for a different day.

Since this is so difficult to figure out, I would like to propose adding a validator that kicks in after the VCS parameters are edited that does a check of the files to make sure they work if SSH is specified by directly calling the libssh2 routines and very explicitly reporting errors that aren't hidden behind the git layer. I don't know how to make something like that work exactly, but better error messages are clearly required.

jmscreation commented 3 months ago

I'm having the same exact issues. This is not working at all no matter what I try.

I've used a PAT token, which works, but every time I re-open the project, the password field is erased. This means I would have to copy and paste the PAT token each time I open the project! This is no good.

Using SSH keys don't work at all no matter what I try. I did use PEM format, but it seems to always try a blank password.

Notes: Windows 10 Godot 4.2.1 stable Plugin Version: v3.1.1

markeel commented 3 months ago

You should be able to use SSH on Windows. Although it caused me grief when I was doing it, once I got the sequence right it worked fine. When you use SSH - test by not putting in a password on the private key. Protect the private key with OS controls (i.e. make it only readable by your user).

The only fields that you need to fill out in the "Version Control Settings..." dialog when you use SSH are

Username: SSH Public Key Path: SSH Private Key Path

Double check that the paths are correct (backslash not forward slash), and that the top of the file in the Private Key Path should look like: ------BEGIN RSA PRIVATE KEY-------

Does the SSH key work when you use git from the command line? If you are using GItHub did you add the key to the list of valid keys in the GitHub account web page?

When I set it up that way on Windows it worked like it was supposed to. One of these days I think I'll try to figure out how to provide better error messages, but it definitely can work.