2

Can't clone a Google Cloud Platform repository to a Google Cloud Platform VM

Issue: When I attempt to clone I get "Permission denied (publickey)"

Setup:

  • Created an SSH key pair on the VM
  • In the Google Cloud Platform VM edited the instance details via the dashboard, added the key, and saved it
  • Started the VM and confirmed in the instance details that the key was registered.
  • On the Cloud Source Repositories dashboard for my repo registered the public key

Attempts:

  • Connected to the instance via ssh from my local terminal, confirmed again that the key existed then attempted to clone the repo. Same permission denied result.
  • Connected to the instance via the terminal created by the remote access button on the GCP instance details dashboard. Same permission denied result.

The keys on my local machine are also registered with Cloud Source Repositories and I am able to clone the repo into my local machine without any problem.

Nibrass H
  • 2,403
  • 1
  • 8
  • 14
GDB
  • 3,379
  • 2
  • 26
  • 38
  • 1
    What command are you running to clone the repo? Did you setup a credential helper in the VM session? – John Hanley Mar 07 '21 at 01:26
  • Using the command provided on the repo dashboard John "Clone this repository to a local Git repository: Clone with command line" . Not familiar with "credential helper". The project is set up by my company as is the service account. I can do pretty much everything else from a ssh session: any file action, interact with BigQuery, read and write to buckets, run ssh JupyterNotebook sessions, etc. Interacting with my GCP Cloud Source Repositories is the only roadblock I've encountered. – GDB Mar 07 '21 at 17:37
  • 1
    What is the command? Details are required. If you are using the `git` command you must setup a credential helper. There are details such as `You cannot configure authentication for service accounts by using SSH keys.` Consult the documentation. https://cloud.google.com/source-repositories/docs/authentication – John Hanley Mar 07 '21 at 19:25
  • Thank you John. I read the documentation. Carefully. Several times. Command: git clone ssh://.com@source.developers.google.com:2022/p//r/ Before running the above command ran gcloud init to confirm that I my configuration is set up correctly, From the _documentation_: "Authenticate by using the Cloud SDK Cloud Source Repositories lets you authenticate by using the Cloud SDK. In this scenario, you run the gcloud init command on your system to set up local authentication." I have done this both on my local and my VM – GDB Mar 08 '21 at 16:12
  • I found _one_ reference to "credential helper" in a three year old SO thread. John I appreciate your good intentions but maybe you should give up on helping me. Thanks. – GDB Mar 08 '21 at 16:16

1 Answers1

1

This issue was resolved with a command different than the one provided by Cloud Source Repositories. Problem was related to the fact that my company set up my account - I don't have the creds to manage it. The clone command provided by provided by Cloud Source Repositories included a reference to the account the company set up which was not accepted even though I used gcloud init on the VM.

I tried using the cloud SDK on the VM. This resulted in the clone being successful: gcloud source repos clone [repo-name] --project=[project-name]

My team is just now migrating from on-prem to GCP and we're hitting the occasional speed bump like this.

By the way, most of the references to "credential helper" on the GCP doc related to Docker. That did not seem relevant to the repo issue.

GDB
  • 3,379
  • 2
  • 26
  • 38