Issue
I didn't find the solution to my problem in similar questions.
Here is what i try to get :
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 ?
Solution
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
Answered By - Yoric Answer Checked By - Senaida (WPSolving Volunteer)