Why is a password asked in Git Source Control when there is an SSH key?

10 views (last 30 days)
I have a Git repository, and when I try to use Source Control integration in MATLAB, it always asks for a password. I have installed the ssh keys, and those work fine in Git for Windows terminal. The keys are placed in the correct location. I have the correct "HOME" environment variable. The output of command "git config --list":
diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=openssl http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt core.autocrlf=true core.fscache=true core.symlinks=false credential.helper=manager user.name=**************** user.email=****************core.symlinks=false core.repositoryformatversion=0 core.filemode=false core.logallrefupdates=trueremote.origin.url=http://****************.com/test/matlab.gitremote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master
How to get rid of the password prompt?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Jan 2025
Edited: MathWorks Support Team on 31 Jan 2025
As it can be seen in the 'remote.origin.url' above, the URL is on HTTP protocol and for SSH authentication, you need an SSH URL.
There are 5 kinds of git servers: [ Read more here: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols ]
  • Local
  • HTTP [You are currently using]
  • HTTPS
  • GIT
  • SSH [This is what you need to override password]
With that said, to overcome this issue, your URL should look like this:
ssh://[user@]server/project.git    OR   [user@]server:project.git
Additional troubleshooting steps:
  • If you follow these steps: Please run the following command in the command window of MATLAB R2020a to access the release-specific documentation:
    >> web(fullfile(docroot, 'matlab/matlab_prog/set-up-git-source-control.html'))
    , then you should have a HOME environment variable set that points to a folder containing a sub-folder .ssh, which in turn should contain your ssh keys. You can run the command "getenv('HOME')" to confirm that this environment variable is set up correctly.
  • Always run "ssh-keygen" in command prompt and not in git cmd.
  • Make sure you added/registered the keys with your git server.
  • Sometimes a proxy in your network can cause issues.
Please follow the below link to search for the required information regarding the current release:

More Answers (0)

Categories

Find more on Source Control in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!