简体   繁体   中英

git clone : Permission denied (publickey) Using Debian

I didn't find the solution to my problem in similar questions.

Here is what i try to get :

  • to clone my server side git repo on a client machine

Command that doesn't work (from the client machine) :

sudo git clone myuser@servermachine:/path_to_repo/repo.git

I'm getting the error:

Cloning into 'repo'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Note: i can login with ssh to the server machine (from the client machine) :

ssh myuser@servermachine

--> ok i'm logged in, without being asked for a password

What i already did :

  • 'ssh-keygen' on my client machine
  • copied ~/.ssh/id_rsa.pub (from client machine) to ~/.ssh/authorized_keys (on server machine)

Additional note :

This exact same clone command works fine from another client machine :

git clone myuser@servermachine:/path_to_repo/repo.git

It should be pretty straightforward but i'm out of idea :'( Anyone got an idea ?

Ok i finally get it to work.

I mixed up my command with "sudo" and this was the main reason it did't work

What i did is :

  • I earesed all the lines on my server machine in file ~/.ssh/known_hosts
  • I cd in a folder i have access to (from client machine), like in ~/
  • I started again the same command, without the sudo, and it worked, hooray !

That is :

git clone myuser@servermachine:/path_to_repo/repo.git

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM