Reputation: 16563
I've been using Google source repos for many years, and now I'm getting permission denied when I try to push or pull.
I've checked everything I can think of:
gcloud components update
gcloud init
The above process sets my account and project so those are all set.
I just tried on a different computer (Windows 10), and I don't get permission denied. The issue has something to do with my Mac setup...
Below are some examples:
$ git pull
remote: PERMISSION_DENIED: The caller does not have permission
remote: [type.googleapis.com/google.rpc.RequestInfo]
remote: request_id: "xxx"
fatal: unable to access 'https://source.developers.google.com/p/project/r/default/': The requested URL returned error: 403
$ gcloud source repos clone default --project=project
Cloning into '/Users/user/TMP/default'...
remote: PERMISSION_DENIED: The caller does not have permission
remote: [type.googleapis.com/google.rpc.RequestInfo]
remote: request_id: "xxx"
fatal: unable to access 'https://source.developers.google.com/p/project/r/default/': The requested URL returned error: 403
ERROR: (gcloud.source.repos.clone) Command '['git', 'clone', 'https://source.developers.google.com/p/project/r/default', '/Users/user/TMP/default', '--config', 'credential.https://source.developers.google.com/.helper=', '--config', 'credential.https://source.developers.google.com/.helper=!gcloud auth git-helper [email protected] --ignore-unknown $@']' returned non-zero exit status 128.
$ git clone ssh://[email protected]@source.developers.google.com:2022/p/project/r/default
Cloning into 'default'...
[email protected]@source.developers.google.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Upvotes: 0
Views: 2830
Reputation: 1341
You probably are using a standard RSA key, which is not supported. You need to use another algorithm. Try creating a new one using the following command:
ssh-keygen -t ecdsa -C "[USER_EMAIL]"
source: https://cloud.google.com/source-repositories/docs/authentication#ssh
Upvotes: 1
Reputation: 96
I also experienced the same. The repo existed and I had the correct permissions, but I still got the same error.
You have to add your ssh key to ssh agent
ssh-agent -s
ssh-add <pathtokey>
eg.
ssh-add ~/.ssh/id_rsa
This worked for me
Upvotes: 0
Reputation: 16563
I found this answer to another to another similar question.
I didn't have the same file mentioned there, but I deleted ~/.netrc
and now git is working.
The .netrc
file has been there since 2017. No idea why that made a difference now...
Upvotes: 0
Reputation: 801
The first you can do is check the repository details and check the access level
and the acces need to be set to write
Then go to tools -> Options and Authentication and delete all the passwords under git saved password
or you could use the following commands:
git config --system -l
You will get,credential.helper=!github --credentials
And then use git config --system --unset credential.helper
to remove the saved credentials (make sure you run this as an admin)
More on the subject on removing the credentials refer to this link
If removing the credentials doesn't work, here is another link to help you with the 403 error using the SSH or modifying the HTTPS URL
Upvotes: 0