Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 18120  / 2 Years ago, sun, may 29, 2022, 8:01:57

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 [email protected]:/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


More From » ssh

 Answers
7

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


If authorized_keys 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

[#32230] Tuesday, May 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
panshow

Total Points: 454
Total Questions: 98
Total Answers: 122

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago
;