Reputation: 453
I've added my public key to the metadata for my project in the developer's console, when I ssh into an Ubuntu VM instance I can see my public key in the file ~/.ssh/authorized_keys
but when I try to use it to clone a project from Bitbucket I receive the error Permission denied (publickey)
If I ssh-add -l
I just get The agent has no identities
. Is there something else I'm supposed to be doing to use my existing public key on GCE instances?
Upvotes: 2
Views: 827
Reputation: 25956
You are mixing up things. There are two keys, public and private (for example ~/.ssh/id_rsa{,.pub}
). You are adding public key where you want to ssh/login and store private key on you computer/computer from where you want to ssh/login.
If you want to use your key pair for cloning from BitBucket from your VM, you need to do one of these things:
ssh-keygen
ssh-add path/to/private/key
ssh -K your-vm
git clone your-repo
ssh your-vm
ssh-keygen
git clone your-repo
The first solution is more useful if you don't want to have many keys and the operations with repository will not happen without your participation (cron jobs). The second one is more helpful if you want to update repo using cron and run some automation on this.
Upvotes: 3