SSH connection error only in Matlab 2021a
9 views (last 30 days)
Show older comments
Dear Matlab-Community,
Whenever I try to connect to my GitLab instance using SSH with Matlab 2021a, I get an error git error (see below). Using SSH in the terminal works fine on all 4 PCs (Windows 10), however using SSH through Matlab doesn't work. This appears to be limited to MATLAB2021a, as one of the machines also runs MATLAB2019b, in which no issues occur and a ssh connection can be established and files can be uploaded and/or pulled.
Error-Message:
Git internal error (Code = -1, Class = 23): Failed to authenticate SSH session: Unable to open public key file
What has been done so far:
- I followed the instructions given here: https://www.mathworks.com/matlabcentral/answers/494543-why-do-i-receive-an-auth-fail-error-when-interacting-with-a-git-remote-over-ssh-in-matlab-or-why-d#answer_404449
- Re-generated the ssh-keys multiple times, always following the command mentioned above:
ssh-keygen -t rsa -b 4096 -m PEM
- Tried various machines (4), which all lead to the same issue
- Check "HOME" and "USERVARIABLE" systemvariables.
- Installed MATLAB2019b to check for isssues with versions --> No issues using this version; ssh connection can be established
- Checking ssh connection from terminal --> all workds nicely.
Thanks for our help!
2 Comments
Olivier Megel
on 11 Nov 2021
Hi Alexander,
I am facing a similar issue although with Matlab 2021b. It works fine on 2019a. Did you manage to solve the issue in the end?
Best,
Olivier
Answers (1)
Chetan
on 8 May 2024
I understand that you're encountering an issue when trying to connect to your GitLab instance via SSH within MATLAB 2021a, with an error message indicating a failure to authenticate the SSH session due to the inability to open the public key file.
It appears MATLAB is not detecting the SSH keys. As a workaround, you can explicitly set the path of your PEM file and personal private key with the following commands:
git = settings().matlab.sourcecontrol.git;
git.PrivateKeyFile.PersonalValue = '/path/to/key';
git.PublicKeyFile.PersonalValue = '/path/to/key.pub';
Additionally, you can follow the steps outlined in the MathWorks Documentation linked below for further guidance:
Hope this helps!
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!