3

I have transfered my ssh key from my root to my user account by ssh-copy-id command

so now I have these files in my .ssh folder

user@user-php:~/.ssh$ ls
authorized_keys  config  id_rsa  id_rsa.pub  known_hosts

Now when I want to clone a project and actually the public key is in authorized_keys file it gives me error

user@user-php:/var/www/ts$ git clone git@xxxx.beanstalkapp.com:/xxxx.git
Cloning into 'xxxx'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

it is not pick up public key form authorized_keys

now why it not picking up the public key and is there any way i can tell git which public key to use.

EDIT: i have also try one more thing i have copyied all the keys from root/.ssh folder to user/.ssh but it still gives Permission denied (publickey). error

6

You need to add the id_rsa.pub contents to the authorized_keys2 file depending on the version of OpenSSH that's installed on the server.

If authorized_keys2 doesn't exist, create it.

Also, make sure that you are copying the public key correctly. What I would do, transfer my id_rsa.pub to the server via sftp, then on the server (via ssh if possible) run:

cat id_rsa.pub >> ~/.ssh/authorized_keys
0

Sorry after some search i found out that to push and pull form git you need privte key for that public key which is kept on the server. so i copied the private the to the .ssh folder and then added it to ssh-agent with

ssh-add command and then i was easily pull and push now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.