Search code examples
gitsshconsolecloud

How to update my google cloud repository ? (facing ssh problems)


I'm facing a problem right now, whether I try to git pull, push or just clone my google cloud console repository, I get this error :

ssh: connect to host source.developers.google.com port 2022: Undefined error: 0
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I have the right access cause I am the owner of the repository. Also, I've generated a new SSH key and added it to the "Manage SSH keys" space of the repository. I've tried several SSH keys types, still no luck. I don't understand cause I used to update it with no issues at all, and I don't remember changing my SSH key before it happened.


Solution

    1. Did you register your public key
      https://cloud.google.com/sourcerepositories/docs/authentication#register_a_public_key

    2. Make sure you have correct permissions for .ssh folder and keys

    The .ssh directory permissions should be 700 (drwx------).  
    The public key (.pub file) should be 644 (-rw-r--r--). 
    The private key (id_rsa) on the client host.
    The authorized_keys file on the server, should be 600 (-rw-------).
    
    1. To debug try ssh to your repo like ssh -vT [email protected]

    2. Look for .ssh/config if exists and configured wrong or have one configured like below

    host source.developers.google.com
    HostName source.developers.google.com
    Port 2022
    IdentityFile ~/.ssh/my_private_key
    User myuser