I am using TortoiseGit on Windows. When I am trying to Clone from the context menu of the standard Windows Explorer, I get this error:
Please make sure you have the correct access rights and the repository exists
More precisely, the snapshot of terminal is the following:
git.exe clone –progress -v “[email protected]:gitAlfaRobot.git” “C:WorkAlfaRobot”
Cloning into ‘C:WorkAlfaRobot’…
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git did not exit cleanly (exit code 128) (21450 ms @ 19.09.2014 10:36:58)
What should I do to make git work properly ?
Your git URL might have changed. Change the URL in the local directory by using the following command
git remote set-url origin [email protected]
That problem might be having with your ssh-agent, your ssh key hasn’t been added with ssh-agent.You have to apply following steps using your terminal:-
$ eval “$(ssh-agent -s)”
Agent pid 5867
Enter passphrase for /home/you/.ssh/id_rsa:  Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)
then it will work..cheers J.
For me it was because of no SSH key on the machine. Check the SSH key locally:
$ cat ~/.ssh/id_rsa.pub
This is your SSH key. Add it to your SSH keys in the repository.
In gitlab go to
profile settings -> SSH Keys
and add the key
Github now uses a url scheme
git remote set-url origin https://github.com/username/repository.git
You are trying to clone the repository over ssh:
[email protected], and your SSH keys are not properly set on server. There are multiple reasons to this:
- Your public key might not be saved in authorized_keys file of user git
- If 1 is not true the Your private key is not saved in .ssh/ folder of your HOMEDIR.
- Permissions are not properly set
If all 3 above are untrue then my only conclusion can be to try:
Assuming AlfaRobot.git is in HOMEDIR of git user and not inside a folder called git which resides in HOMEDIR of user git.
If it was working before and suddenly stopped working:
This issue can be caused because sometimes
ssh-agent is not persistent across reboots. You should check if
ssh-agent has your key added:
ssh-add -l -E md5
if you get the output like:
The agent has no identities.
ssh-agent has lost your key. In that case, you simply need to add the identity key again. Something like:
The error should disappear now!
The rsa.pub (i.e. public key generated), needs to be added on the github>> settings>>ssh keys page. Check that, you have not added this public key in the repository-settings >> deployment keys. If so, remove the entry from here and add to the first place mentioned.
Setup of the pub-private keys in detail.
It will work hence!
If you’re on a shared machine, using your own password or passwordless private key might be overkill. The safer option is an access token:
- Go to Settings, Developer Settings, Personal access tokens
- Generate new token.
- Note what the token is for.
- Grant repo access.
- Clone the repo:
$ git clone https://<token>@github.com/<user>/<repo>.git
If you’ve already cloned the repo, you could just modify your remote setting:
$ git remote set-url origin https://<token>@github.com/<user>/<repo>.git $ git pull Already up to date.
The first thing you may want to confirm is the internet connection. Though, internet issues mostly will say that the repo cannot be accessed.
Ensure you have set up ssh both locally and on your github. See how
Ensure you are using the ssh git remote. If you had cloned the https, just set the url to the ssh url, with this git command
git remote set-url origin [email protected]:your-username/your-repo-name.git
If you have set up ssh properly but it just stopped working, do the following:
eval "$(ssh-agent -s)"
If you are still having the issue, check to ensure that you have not deleted the ssh from your github. In a case where the ssh has been deleted from github, you can add it back. Use
pbcopy < ~/.ssh/id_rsa.pubto copy the ssh key and then go to your github ssh setting and add it.
I will recommend you always use ssh. For most teams I’ve worked with, you can’t access the repo (which are mostly private) except you use ssh. For a beginner, it may appear to be harder but later you’ll find it quite easier and more secured.
I had this problem, and i discover that my system was with wrong dns address. Verify your network and test with
ssh -vvv [email protected]
And read the output messages. If you see “You can use git or hg to connect to Bitbucket.” , everything is ok.
I come across this error while uploading project to gitlab. I didn’t clone from git but instead upload project. For pushing your code to gitlab you have two ways either using ssh or https. If you use https you have to enter username and password of gitlab account. For pushing you code to git you can use following one.
Pushing to Git for the first time
>$ cd >$ mkdir .ssh;cd .ssh >$ ssh-keygen -o -t rsa -b 4096 -C "[email protected]"
The -C parameter is optional, it provides a comment at the end of your key to distinguish it from others if you have multiple. This will create id_rsa (your private key) and id_rsa.pub (your public key). We pass our public key around and keep our private key — well, private. Gitlab’s User Settings is where you would then add your public key to your account, allowing us to finally push.
In your project location(Directory) use below command
It Transform the current directory into a Git repository. This adds a .git subdirectory to the current directory and makes it possible to start recording revisions of the project.
Push Using https path
git push --set-upstream https://gitlab.com/Account_User_Name/Your_Project_Name.git master
Push Using ssh path
git push --set-upstream [email protected]:Account_User_Name/Your_project_Name.git master
— set-upstream: tells git the path to origin. If Git has previously pushed on your current branch, it will remember where origin is
master: this is the name of the branch I want to push to when initializing
Here is how I solve this issue. I was using Babun(mintty.exe) on Win7/10. When I have tried many solutions mentioned above, and none of them works. I realized maybe I just used wrong ssh agent…
So I run
echo $GIT_SSH to find out, it shows the path to
What I actually expected is OpenSSH.
So, I add following one-liner to
Note 1: You can execute it in babun directly also
Note 2: You if you use bash then the config file is
export GIT_SSH=$(which ssh)
And It works!
add these lines to your
.get/config file (thanks to @kovshenin answer Git Pull: Change Authentication) :
[credential] helper = wincred
Try https instead of ssh. Choose the https option from project home page where you copy the clone url from.
I’m using Ubuntu
after reading many of answers, none of them can solve the problem, even if I already added SSH key to my git account, and try test it using
ssh -T [email protected] and it said
Welcome <my username>, but it still kept telling me that I don’t have access rights. Then I found the reason:
Normally if you’re not
root user, it will require you to run with
sudo for every git command.
sudo git clone <SSH....> (for example). it will be executed under
root permission, but accidentally when create SSH key I run it as normal user and I save the key in
~/.ssh/id_rsa, it resolves the absolute path
/home/username/.ssh/id_rsa. And when doing
sudo git clone ... it looks for SSH key in
Why I can sure about this. To see where git looks for your SSH key. Run this command:
sudo GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone <your repository in SSH>. It will show you where it looks for your SSH key.
So the SOLUTION I suggest is:
Re-creating your SSH key (follow this instruction), BUT run
sudo su at the very first step, then you’ll should be fine.
This can also happen if you are connecting to your git repository through a VPN. Make sure that you are connected to the VPN which is used to access the resources of your organization.
For me i was having issue with company VPN, after disconnecting working fine.
Check connection with github using command
ssh -vvvT [email protected]
An alternative problem may be your internet connection. Obvious maybe, but took me a few minutes to figure out my wifi was down 🙂
Like other answers, use
https instead of
ssh was the solution.
I post an answer to give a concrete example of a possible solution. I solved this issue with bitbucket when I changed remote url to HTTPS with this command line:
git remote set-url origin <bitbucket_URL>
After that, I could push the content to the repository with this command:
git push -u origin --all
And then I could also use Sourcetree
Strangely I only received this error in 1 of my many repos.
My issue was after installing the new GitHub Desktop for Windows where the previous old GitHub for Win kept keys in
~/.ssh/github_rsa.pub where as the new GitHub for Win expects it in
~/.ssh/id_rsa so the solution was just renaming the existing private and public keys:
~/.ssh/github_rsa -> ~/.ssh/id_rsa ~/.ssh/github_rsa.pub -> ~/.ssh/id_rsa.pub
After which let me access the repo again without issue.
use your https origin instead of ssh url
git remote add origin https://gitlab.com/user/folder.git
Adding ssh key worked for me. You can create ssh key with ssh-keygen command on mac. You should be able to see Deploy keys menu on YourRepository>Settings don’t forget to check Allow write access option.
Very common mistake was done by me. I copied using clip command
xclip -sel clip < ~/.ssh/id_rsa.pub, but during pasting into github key input box, I removed last newline using backspace, which actually changed the public key.
So, always copy & paste ssh public key as it is without removing last newline.
Switching to the use of https works. First switch to https rather than ssh keys. git remote set-url origin
It will then request for the git username and password.
I experienced this issue when I had an invalid RSA SSH key, and a valid ED25519 SSH key on my machine. I believe Gitlab was checking the RSA key, failing and stopping there before checking the ED25519 key.
I fixed this by deleting both of the keys I had on my device and generating a new RSA SSH, and providing that too gitlab.
For me it gave the same error of:
Please make sure you have the correct access rights and the repository exists.
A quick fix was to eliminate the ~/.ssh/config file
mv config config_old && touch config eval "$(ssh-agent -s)" git clone your_repo As it turned out to be the config file that was corrupt and configured with two ids