Problem solved, there is quite simply a typo in the MATLAB-Help "Set Up Git Source Control": the key-filenames "25519..." are mixed with "25119...". Although obvious, it was difficult for me to see.
Failed to authenticate SSH session: Unable to open public key file
42 views (last 30 days)
Show older comments
Martin Kowalski
on 19 Dec 2022
Commented: Paul Bergman
on 3 Mar 2023
After updating to MATLAB R2022b I cannot connect to the gitlab repo of my project anymore. When trying to push/pull or clicking on Source Control -> Remote -> Validate, I get always the message:
Unable to validate the specified path with the following git error: Unable to connect to the remote ssh://git@gitlab.tuwien.ac.at:822/...
Caused by: Failed to authenticate SSH session: Unable to open public key file
I followed all steps in the MATLAB-Help "Set Up Git Source Control". Tried to generate new keys, validated that they I can connect to my repo using these keys (outside matlab), validated the git.PrivateKeyFile.PersonalValue, git.PublicKeyFile.PersonalValue settings in MATLAB, validated filenames / paths / HOME-environment variable.
What else can I try? Thx for help!
0 Comments
Accepted Answer
Martin Kowalski
on 27 Dec 2022
3 Comments
Paul Bergman
on 3 Mar 2023
Stared this for awhile...
git = settings().matlab.sourcecontrol.git;
git.PrivateKeyFile.PersonalValue = "C:\Users\username\.ssh\id_ed25119";
git.PublicKeyFile.PersonalValue = "C:\Users\username\.ssh\id_ed25119.pub";
Needs to be:
git = settings().matlab.sourcecontrol.git;
git.PrivateKeyFile.PersonalValue = "C:\Users\username\.ssh\id_ed25519";
git.PublicKeyFile.PersonalValue = "C:\Users\username\.ssh\id_ed25519.pub";
For those of us who scan things too quickly when reading. (... also you can copy and paste. )
:)
Thanks for the answer, it helped!
More Answers (1)
Ritish Sehgal
on 27 Dec 2022
I assume that you have already followed the documentation below:
But from the error message, it might be possible that the path was not set correctly. Ensure that the file for the private key and the public key point to a specific file and not just the directory.
You can verify this by running the below commands in your MATLAB command window:
>> git = settings().matlab.sourcecontrol.git;
% This should have the value '...\.ssh\<private_key_file>' and not '...\.ssh\'
>> git.PrivateKeyFile.PersonalValue
% This should have the value '...\.ssh\<public_key_file>.pub' and not '...\.ssh\'
>> git.PublicKeyFile.PersonalValue
If the above values are not set correctly, you can set them as follows:
>> git.PrivateKeyFile.PersonalValue = "C:\Users\<username>\.ssh\<private_key_file>";
>> git.PublicKeyFile.PersonalValue = "C:\Users\<username>\.ssh\<public_key_file>.pub";
Also, if your SSH key is passphrase protected but you do not specify this within MATLAB, then you will encounter an error. In this case, you must use the following command, so MATLAB knows the key pair is passphrase protected:
>> git = settings().matlab.sourcecontrol.git;
>> git.KeyHasPassphrase.PersonalValue = true;
If you think that your keys are passphrase protected but you do not know that passphrase, there is no way to reset the passphrase. Instead, you will have to generate a new SSH key pair.
It is also worth noting that, for the command line version of git, you can specify the paths to your SSH keys in a “.ssh/config” file, MATLAB does not read this file. You will still have to follow the steps in the above documentation to make your keys visible to MATLAB.
Hope it helps!!
See Also
Categories
Find more on Environment and Settings 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!