0

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:

  • Updated gcloud: gcloud components update
  • Reinitialized: gcloud init
  • Reinstalled gcloud tools
  • Updated git
  • Cloned repo to new directory (no permission)
  • I still have access on the console: https://source.cloud.google.com/project/default
  • Closed and reopened terminal
  • I'm the owner of the organization and the project but I also added all source repository permissions

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 --account=me@example.com --ignore-unknown $@']' returned non-zero exit status 128.

$ git clone ssh://me@example.com@source.developers.google.com:2022/p/project/r/default
Cloning into 'default'...
me@example.com@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.
new name
  • 15,861
  • 19
  • 68
  • 114
  • 1
    Messages prefixed with `remote:` are coming not from Git itself, but from something the "remote Git" (the software running on your hosting provider, in this case Google) is running. That something, whatever it is, *should* tell you what is wrong and how to fix it. Git can't because as far as Git knows, everything is just fine. Git is just relaying a message. – torek Jan 14 '22 at 18:35

4 Answers4

1

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

Daniel
  • 1,321
  • 12
  • 25
0

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

0

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...

new name
  • 15,861
  • 19
  • 68
  • 114
0

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