Reputation: 7280
I want to clone a repository to an EC2 instance I'm using. I generated ssh key pair using "ssh-keygen".
Your public key has been saved in /home/ubuntu/.ssh/id_rsa2.pub.
the id_rsa2.pub looks something like:
ssh-rsa a_very_long_sequence ubuntu@ip-a-b-c-d
I pasted the key as it is to the keys associated with my bit bucket account. But I'm being prompted
Invalid SSH key (ssh-keygen).
Upvotes: 4
Views: 4019
Reputation: 2106
So what might be a problem is that you add your SSH-key as the ubuntu
user, but you git clone
the repository with sudo
.
So what you need to do, if you use sudo git clone [email protected]:username/repo.git
, you need to get the id_rsa.pub
from the root user and add it to Bitbucket (or Git?):
sudo su - root # switch to root user
cat ~/.ssh/id_rsa.pub # create if not already existing
sudo su - ubuntu # switch back to normal user
Now I can pull/clone from my repository without password authentication.
Upvotes: 4
Reputation: 1328972
.ssh/id_rsa2.pub isn't the default name an ssh session will look for to pass to the server.
Try and rename your keys in
.ssh/id_rsa
.ssh/id_rsa.pub
Or use a ~/.ssh/config
file to point to the right private/public keys.
Upvotes: 2