Copy that key and follow your provider’s advice for setting up the public key.
For example, in Clouse Source Repositories it looks like this:
Configure .ssh/config
I’ve already got a GitHub setup for my personal account.
Using ssh-agent gives us a way to config all this using the ~/.ssh/config files.
If it does not already exist just touch ~/.ssh/config to create it.
Adding the Cloud Source Repo section for this specific repository looks like this.
Note the hostname that this ssh keypair will apply to:
1
2
3
4
5
6
Host *.github.com
AddKeysToAgent yes
IdentityFile ~/.ssh/id_github_personal
# New bit
Host *.source.cloud.google.com:2022/fleetrouting-app-ops/fleetrouting-app
IdentityFile ~/.ssh/id_gcp_csr_fleetrouting
Now if you try your git clone it’ll fail, even though it found the correct key to us based on the host:
1
2
3
4
5
6
7
8
9
10
$ git clone ssh://dylan.thomas@woolpert.com@source.developers.google.com:2022/p/fleetrouting-app-ops/r/fleetrouting-app
Cloning into 'fleetrouting-app'...
The authenticity of host '[source.developers.google.com]:2022 ([74.125.126.82]:2022)' can't be established.
ECDSA key fingerprint is SHA256:AGvEpqYNMqsRNIviwyk4J4HM0lEylomDBKOWZsBn434.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[source.developers.google.com]:2022,[74.125.126.82]:2022'(ECDSA) to the list of known hosts.
dylan.thomas@woolpert.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.
I used this for github.com as well.
The problem there is a single domain (HostName) with two different keys. What to do?
Previously I did not have the IdentitiesOnly yes in there, and even though I was not attempting to push changes to a repository under github.com/woolpert, my Woolpert identity was getting used.
1
2
3
4
5
$ git push
ERROR: Permission to dvhthomas/bitsby.me.git denied to dylanthomas-woolpert.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
Grrr. A footnote to a StackOverflow post pointed me in the right direction.
So by adding the IdentitiesOnly yes to both entries: