1

I'm getting this error from the terminal (ubuntu), although if I write ssh -T git@github.com I appear to be authenticated. I've just added a new ssh key, and I have a global config file. I've already tried different solutions found online, with no luck.

Can anyone help please?

I've tried

`git push -u origin master` or `git push -u origin main`

and this is the output of git remote:

$ git remote -v
origin  https://github.com/loucat-dev/github-test.git (fetch)
origin  https://github.com/loucat-dev/github-test.git (push)
origin  git@github.com:loucat-dev/github-test.git (push)
loucat dev
  • 51
  • 2
  • 6

1 Answers1

0

"invalid username or password" is not an error you would find with an SSH URL, but rather with an HTTPS one, as I detail here.

Try:

cd /path/to/local/repo
git remote set-url git@github.com/<me>/<myrepo>

Then you can add, commit and try to push, to validate that the authentication does work when writing back to your remote GitHub repository.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi @VonC, I've tried that (adding "origin" before the repo url, as in your original post), but after I authenticate it still says Authentication Failed :( – loucat dev Oct 14 '20 at 12:24
  • @loucatdev The git remote you just added in your question is still showing an HTTPS URL, not an SSH one. – VonC Oct 14 '20 at 12:27
  • I've retried and after adding the remote with SSH, now the last entry is SSH (see the edited question). Still when I try to push it doesn't authenticate me – loucat dev Oct 15 '20 at 17:13
  • @loucatdev yes, because it will also use the https URL when pushing – VonC Oct 15 '20 at 17:45
  • Ok, I've removed the remote completely (including origin), then I added it back using the ssh url, and now it all works. Thanks! – loucat dev Oct 15 '20 at 18:18