SSH connection error only in Matlab 2021a

9 views (last 30 days)
Alex
Alex on 8 Nov 2021
Answered: Chetan on 8 May 2024
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:
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
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
Alex
Alex on 11 Nov 2021
Hi Olivier,
So far I could't solve the problem. I updated my MATLAB R2021a - Update 5, but this didn't change anything.
Best,
Alexander

Sign in to comment.

Answers (1)

Chetan
Chetan on 8 May 2024
Hi @Alex,
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!

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!