Borrar filtros
Borrar filtros

SSH Key for GitHub not working (MacOS)

9 visualizaciones (últimos 30 días)
Javier Montemayor
Javier Montemayor el 19 de En. de 2019
Comentada: Renato Busatto el 19 de Feb. de 2021
I've done what's stated in this post to enable GitHub auth without having to enter username and password over and over https://www.mathworks.com/matlabcentral/answers/263934-every-time-i-push-to-the-remote-github-repository-i-have-to-re-input-my-username-and-password-is-t
Yet, when I try to push a commit, I get the following error message:
git@github.com:username/repository.git: invalid privatekey: **********
(There are some characters instead of the **********)
I'm running MATLAB R2017b on a MacBook Pro 15" 2018 with MacOS Mojave 10.14.2
I also have a config file inside my .ssh folder with the following text:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
The contents of my id_rsa.pub are on my GitHub account's SSH keys.
Does anybody know a solution for this issue?
  4 comentarios
Mike Kokko
Mike Kokko el 13 de Mzo. de 2019
I'm having similar issues with R2018b. This integration worked nicely for me on other machines in the past. Git seems to be configured fine from the command line to use the public key but pushing from MATLAB results in an error:
git@github.com:user/repo.git: Auth fail
Javier Montemayor Mancías
Javier Montemayor Mancías el 13 de Mzo. de 2019
I ended up using GitHub Desktop for my personal account (I now have my work account in the command line). Would be nice if the integration worked, though.

Iniciar sesión para comentar.

Respuestas (3)

Timothy Koehler
Timothy Koehler el 23 de Oct. de 2019
Apparently, newer versions of Git (2.23) have key generation using OPENSSH private keys. If your key that gets generated starts with:
----BEGIN OPENSSH PRIVATE KEY----
then you may need to try using this option
-m PEM
when generating your keys. We have found that the following command for key generation will fix the problem.
ssh-keygen -m PEM -t rsa -b 4096 -C "yourmail@foo.com"
  4 comentarios
Francois Gardavaud
Francois Gardavaud el 12 de Nov. de 2020
This works. Thank Mister Koehler.
Tested on macOS Catalina 10.15.7 & Matlab 2020b.
Renato Busatto
Renato Busatto el 19 de Feb. de 2021
It took me hours to realise that the public key MUST be named "id_rsa". Any other name will give an "invalid privatekey" error.

Iniciar sesión para comentar.


Rubens Rossi
Rubens Rossi el 6 de Sept. de 2019
Hello, I have also Git on my path but I still get "auth fail". It says that "The authenticity of host xxx can´t be established".
However, when I push or pull from the Bash I do not get any error.
I use Matlab 2019a on Windows, Git version Git-2.23.0-64-bit.

Colm Bates
Colm Bates el 26 de Jun. de 2019
I had the same problem on 2018a.
Local Git integration worked fine, however when trying to push to a remote Bitbucket repository I got the following error.
matlabGitError2.png
After researching and reading every Matlab Git article I could find and not finding a solution, I realised the solution was in the first place I looked: The Matlab Set-up source control guide.
This document requires that we install command line git. I ignored this, because I had command-line git installed since before I started using Matlab. This was a mistake. The following is very relavent.
  • 2. In the section on adjusting your PATH, choose the install option to Use Git from the Windows Command Prompt. This option adds Git to your PATH variable, so that MATLAB can communicate with Git.
One can investigate the PATH variable on Windows in Matlab with the following:
[status, output] = system("echo %PATH%");
mypath = split(output, ";");
mypath(~cellfun(@isempty,regexp( mypath, '.*Git.*')))
ans =
0×1 empty cell array
Which shows that there are no references to Git in the path. If you want you can scan through the elements of mypath to make sure.
So I uninstalled Git and reinstalled it. Then when I was presented with the below dialog, I chose the middle option, which states that you will allow Git to be used also from 3rd-party software.
GitConfigSetUp1.PNG
After this I closed Matlab and restarted my computer. And now it works!
I ran the above code and got hte following output:
ans =
1×1 cell array
{'C:\Program Files\Git\cmd'}
Which further suggests the PATH was the issue all along.
  2 comentarios
Jiyo Palatti
Jiyo Palatti el 6 de Sept. de 2019
I do have Git on my PATH and I ge this when I run the command.
ans =
1×1 cell array
{'C:\Program Files\Git\cmd'}
But I still get the same error saying "Auth Fail"
Dmitry Boltyanskiy
Dmitry Boltyanskiy el 28 de Sept. de 2019
Editada: Dmitry Boltyanskiy el 28 de Sept. de 2019
Hm... strange idea. I have the same answer from Matlab: "ans = 0×0 empty cell array". But the command Git works in any directory (I work on Ubuntu). And unfortunately, I can see "Unable to pull in changes. git@github.com:MyUsername/MyProject.git: Auth fail". Also, this error appears only I try to use SSH-authorisation. HTTP-authorisation works, but I do not want to enter login-password every time.
Upd. The "git" command locates in /usr/bin/ folder in my case.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by