SSH Key for GitHub not working (MacOS)
조회 수: 4 (최근 30일)
이전 댓글 표시
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
Mike Kokko
2019년 3월 13일
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
2019년 3월 13일
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.
답변 (3개)
Timothy Koehler
2019년 10월 23일
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
Francois Gardavaud
2020년 11월 12일
This works. Thank Mister Koehler.
Tested on macOS Catalina 10.15.7 & Matlab 2020b.
Renato Busatto
2021년 2월 19일
It took me hours to realise that the public key MUST be named "id_rsa". Any other name will give an "invalid privatekey" error.
Rubens Rossi
2019년 9월 6일
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.
댓글 수: 0
Colm Bates
2019년 6월 26일
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.
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.
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
Jiyo Palatti
2019년 9월 6일
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
2019년 9월 28일
편집: Dmitry Boltyanskiy
2019년 9월 28일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Source Control에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!