Reputation: 3167
I am unable to clone a Git repository, and getting this error:
krishna.soni@KRISHNACHANDRAS /c/Projects $ git clone http://stage.abc.com:10088/pqr
http://<url>/<repository> Cloning into '<repository>'... fatal: could not read Username for 'http://<url>': No such file or directory
I've read Bitbucket, Windows and “fatal: could not read Password for”, but still have the problem.
I proceeded further but am now getting this error
sh.exe": chown: command not found
krishna.soni@KRISHNACHANDRAS /c
$ git clone ssh://[email protected].
/projects
Cloning into 'C:/projects'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
> krishna.soni@KRISHNACHANDRAS /c
> $ git clone ssh:<url>
> ts
> Cloning into 'C:/projects'...
> Permission denied (publickey).
> fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Upvotes: 254
Views: 894137
Reputation: 1718
sudo ssh-keygen -t ed25519 -C "[email protected]"
sudo cat /var/root/.ssh/{generated}.pub | pbcopy
Upvotes: 2
Reputation: 3790
After logging into bitbucket through the browser, my push to origin starting working.
Upvotes: 0
Reputation: 41
I have been facing the same issue, suddenly it clicked to my mind what could go wrong.
Here is what I was doing wrong
While generating the ssh key was using the below command, but I wasn't using sudo and while cloning I was using "sudo git clone ssh_repo_url", because while cloning I need folder to be created which my user doesn't have the permission
My Wrong way to generate ssh
$ ssh-keygen -t ed25519 -C "[email protected]"
The correct way, if while cloning using sudo
$ sudo ssh-keygen -t ed25519 -C "[email protected]"
Upvotes: 0
Reputation: 17054
For people that come here that are just trying to get the repository but don't care about the protocol (ssh / https), you might just want to use https instead of ssh (if it's supported).
So for example you use
git clone https://github.com/%REPOSITORYFOLDER%/%REPOSITORYNAME%.git
instead of
git clone [email protected]:%REPOSITORYFOLDER%/%REPOSITORYNAME%.git
Note that GitHub deprecated password authentication (https login) for private repositories due to it not keeping up with the latest security standards, use a personal access token.
Note also that since March 1, 2022, Bitbucket users are no longer able to use their Atlassian account password with git over https as well, but instead need to use Bitbucket app passwords.
Upvotes: 308
Reputation: 8969
I faced the same problem with GitHub. Here's how to solve it!
git clone
the project.Upvotes: 46
Reputation: 149
For Fedora 33+ and Bitbucket users:
The issue happens because the hash algorithm is outdated. As mentioned on Bitbucket there are two options:
Add to the ~/.ssh/config
file. (If the file doesn't exist, just create it.)
Host bitbucket.org
PubkeyAcceptedKeyTypes +ssh-rsa
Using a more secure algorithm.
ssh-keygen -t ed25519 -C "[email protected]"
Upvotes: 8
Reputation: 16820
After changing permissions of folder in which I was cloning, it worked:
sudo chown -R ubuntu:ubuntu /var/projects
Upvotes: 5
Reputation: 337
I followed the steps detailed in Generating a new SSH key and adding it to the ssh-agent and
Auto-launching ssh-agent on Git for Windows.
In my case ~/.profile
file was not present in my Windows.
I had to create it, then added the script provided in the above link.
Upvotes: 0
Reputation: 29
Remove remote origin
git remote remove origin
Add HTTP remote origin
Upvotes: 1
Reputation: 591
if none of these answers help and
Try
Then, you will find after git clone and type yes to confirm, it should begin to clone
Upvotes: 0
Reputation: 134
I see this errormessage has a lot of different reasons. I had the same error when trying to set up locally another repository alongside one already fully working with ssh etc. and connect it to same server, but other repository. No answers were here to be found, but I figured it out. So I post it. Hopefully helps someone.
git remote add origin [email protected]:teamalpha/repositorytwo.git
Upvotes: 0
Reputation: 187
solution: On the server you are trying to clone to or push from cat ~/.ssh/id_rsa.pub Go to GitHub, settings, SSH and GPG Keys , New SSH key paste key.
Upvotes: 0
Reputation: 3497
If there is still issue around access after creating SSH and adding it in your Bitbucket account or wherever, you need to do the following in terminal on GitBash, OSX or Linux:
# Lists already added identities (‘ssh keys’)
ssh-add -l
Then, if you don't see your key listed, add it with the following (replace identity
with its real name):
# Add a new identity
ssh-add ~/.ssh/identity
This worked for me.
Upvotes: 173
Reputation: 3853
You can try adding your ssh key to your private keychain. It worked for me
ssh-add -K ~/.ssh/[your-private-key]
Upvotes: 3
Reputation: 3733
I had the similar issue. I change the ssh keys and restarted and tried all other 'n' solutions. But the actual issue for me was our gitlab default protocol changed from ssh to https.
check the remote url with
git remote -v
change the remote url
git remote set-url origin https://URL
Upvotes: 10
Reputation: 8403
fix for hub
cli tool:
git config --global hub.protocol https
for long termgit remote add OOPS https://github.com/isomorphisms/go.git
&& git push OOPS
for immediate fixThis error occurs with the hub
command line tool because of their wrong default hub.protocol
git-config value. They set repos to
git://github.com/schacon/ticgit.git
instead of what github actually accepts, namely https://github.com/schacon/ticgit.git
.
Reading LESS=+/"HTTPS instead" man hub
will explain where the above "long-term fix" command comes from.
Upvotes: 2
Reputation: 7802
Useful thread and I don't bring much new to the table. The step I took is also part of the description Maxime helpfully points to but some may overlook it. The section is Adding your SSH key to the ssh-agent.
I had already generated my ssh-key but after a reboot I was unable to clone one of my own repositories.
I had to start the ssh-agent and add the private key to this agent in order to clone.
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
Upvotes: 6
Reputation: 35595
I wanted to clone an open source project so I could submit some pull requests. The problem was that I didn't have permissions from the owner of the project. No matter, since my intention was to submit a PR, here is a viable alternative:
My solution:
Upvotes: 1
Reputation: 1101
I was facing the same issue while setting up ssh for gitlab. I already have ssh for github
and i could not overwrite that.
The steps that worked for me are :
ssh-add /path/to/new/id_rsa
.config
in ~/.ssh/
using. I used vi ~/.ssh/config/
.# GitLab.com server
Host gitlab.com
RSAAuthentication yes
IdentityFile /path/to/new/id_rsa
After that restart the terminal and try pushing, it should work
Upvotes: 0
Reputation: 703
1. To Authenticate you need to add your public part of your SSH key pair to bitbucket from within your user settings: User Settings --> SSH keys
You will find the said public part in your ~/.ssh directory, usually id_rsa.pub
. note the .pub
part of the file name for Public.
it will help you to generate one if you don't already have one
You are not done yet ...
2. You need to let your system know what key to use with which remote host, so add these lines to your ~/.ssh/config file
Host bitbucket.org
IdentityFile ~/.ssh/PRIVATE_KEY_FILE_NAME
Where PRIVATE_KEY_FILE_NAME
is the name of private part of your SSH key pair, if you haven't messed with it, usually its default name is : id_rsa
in this case replace PRIVATE_KEY_FILE_NAME
above with id_rsa
(the private key DOES NOT have a .pub
extension)
Upvotes: 6
Reputation: 14581
I had the same error. My solution was to logout and login again as my ssh-agent had become out of sync with the remote ssh key.
Adding this here just in case anyone has seen that the other answers don't seem to apply to their situation.
Upvotes: 0
Reputation: 4320
I've had this issue on a Mac - while I setup SSH correctly to access my Git repository, after restart (and some time the Mac was on a standoff), all my credentials were removed. Apparently, for some reason the pub key was set to 644 which caused it to be removed from the keychain. To readd:
chmod 600
the public keyssh-add ~/.ssh/[your private key]
- this should display that identity has been added. The key file you want is the one without the .pub extension.ssh-add -l
should show you newly added identityedit: apparently MacOS has tendency of removing keys - after downloading the High Sierra update (but I've not installed it yet) my key has been removed and I've had to add it again via ssh-add
Upvotes: 25
Reputation: 3511
If you generate new public ssh key and inserted it to bitbucket or github and
it not helped - please try to restart your PC. It helped me!!
Upvotes: 7
Reputation: 720
Github(or Bitbucket) can't find your ssh key in their server.
Just add your key in your account setting.
Upvotes: 8
Reputation: 181
For me, when i wanted to clone from my repository, i had the same message noticed before "Permission denied (publickey) fatal: Could not read from remote repository". The solution for my case is to not use sudo before clone That's it.
Upvotes: 18
Reputation: 291
I got the error...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
...when I was trying to make contact from a Git Bash prompt to Bitbucket after my laptop died from a bad Windows 10 update and was returned to factory settings. I had restored all my ssh files from a backup.
The cause of the error turned out to be a mismatch in my Windows account name after the computer rebuild. I learned that the public key file id_rsa.pub
ends with an easily readable string comprising my Windows account name followed by an @
sign and then the computer name.
When I originally set up my computer, I created my Windows account name including my middle initial but when my computer was reset to factory settings, our new DevOps guy created my account name without my middle initial.
To resolve the issue, I simply edited my public key file id_rsa.pub
and removed the middle initial in my name at the end. I had stuck with the same computer name so that was okay. I copied the file contents to the Windows clipboard. I then signed into Bitbucket, went to Bitbucket Settings under my avatar, and added a new public key where I pasted in the new contents.
Back at the Git Bash prompt, I confirmed that it now worked by entering the command...
ssh -T [email protected]
...and I got back a message that I was signed in.
Upvotes: 5
Reputation: 39
While cloning, I had a similar issue [ my ERROR: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights .. etc ]
-- I was using bitBucket/UBUNTU14.04 in my case, but ALREADY had a set of key files that I had previously generated AND I had changed the name of the files. I simply COPIED the files to the standard id_rsa & id_rsa.pub name format. I then re-ran the command with out issue.
OBTW: I could have also used the password prompt by using the HTTP style clone.
Upvotes: 1
Reputation: 1066
If all fails, as was the case with me, Uninstall GIT, reinstall. For some reason this fixes.
P.S.
Upvotes: 2
Reputation: 186
It may be stupid but it happened to us:
If you are using bitbucket and Sourcetree and you just copy paste the clone URL to the new repo dialog it will show the same error when pulling or pushing.
Make sure you delete the 'git clone' stuff before the URL.
Upvotes: -2
Reputation: 724
I had a similar problem on linux. I solved the problem by logging into the github server and creating a deploy key. That's under settings for the repository. Then, I copied and pasted my public key (which is usually in ~/.ssh/id_rsa.pub, but your configuration might be different). There is a check box to give this key write access. Click on it (unless you are using git to deploy only, in which case, don't click on it).
Upvotes: 0