Failed to authenticate SSH session: Unable to open public key file

45 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Martin Kowalski
Martin Kowalski il 27 Dic 2022
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.
  3 Commenti
Alec Bowman
Alec Bowman il 11 Gen 2023
I have been fighting this for literally months. Thank you!
Paul Bergman
Paul Bergman il 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!

Accedi per commentare.

Più risposte (1)

Ritish Sehgal
Ritish Sehgal il 27 Dic 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!!
  1 Commento
Martin Kowalski
Martin Kowalski il 27 Dic 2022
Thank you for the answer, the filename for the ssh-keys was wrong because I copy and pasted it from the MATLAB help. Problem solved.

Accedi per commentare.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by