0

I'm trying to connect git using SSH on ubuntu EC2 instance.

I tried with following steps, I'm getting public key error.

  • Generated SSH using command ssh-keygen and added that key in bitbucket.
  • Edited ~username/.ssh/authorized_keys and added key generated.
  • when i run command ssh -T git@bitbucket.org, i see following result,

    logged in as user-name
    
    You can use git or hg to connect to Bitbucket. Shell access is disabled
    
  • If i do git pull in project directory , I'm getting error

    git@bitbucket.org: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

Help me to get rid of this error.

Note : I tried with following solution, it didn't work. git push origin master: permission denied (public key) error

Note (Updated) :: It works in my local machine(windows) with SSH key.

Allabakash
  • 1,969
  • 1
  • 9
  • 15

2 Answers2

0

You might need to change the permission of keys and folder.

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

You may also need to change the permissions of your home directory and remove write access for the group and others.

chmod go-w ~

This helped me answer your question.

amsh
  • 3,097
  • 2
  • 12
  • 26
0

I tried with following solution, it worked.

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

This is referred from Unable to add ssh-key of EC2 instance to bitbucket account

Allabakash
  • 1,969
  • 1
  • 9
  • 15