0

I'm trying to copy the public key to my remote host but I keep getting this message, "Permission denied (public key).

enter image description here

Password authentication is set to YES in my /etc/ssh/sshd_config file, I have started again from scratch with these commands :

$ssh-keygen -t rsa 
$ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/id_rsa 
$ cat id_rsa.pub >> ~/.ssh/authorized_keys 
$ chmod 600 ~/.ssh/authorized_keys 

Anybody can help me with this please ?

  • Have you checked the manpage of ssh-copy-id, how it tries to install the public key on the new host? – ott-- Mar 6 '16 at 16:05
  • Yes I did! but still I keep having the same issue, I dont know what I'm missing here ! – Samirtow Mar 6 '16 at 16:11
  • You can't use publickey auth because the key isn't there yet. You need to enable password once, after that you can disable that again. – ott-- Mar 6 '16 at 16:19
  • 1
    Please do not post screenshots of text. Copy-paste the text. – Gilles Mar 6 '16 at 16:28
  • Additionally (to the comment by ott), you need to specify the user for whom the key shall be added 'user@192.168.1.20' – gerhard d. Mar 6 '16 at 16:29
0

You miss a basic point in what you do. You need to make sure what is server, what is client and what you want to achieve.

  • You generate the keys on client (your computer)
  • You set up server using sshd_config and you want to have authorized_keys on the server (that IP in the image).

If you did the above, you are able to restart sshd server using service sshd restart and connect to localhost, such as ssh localhost.

If you want to connect somewhere else (as the above IP), you need to allow the password authentication and restart there (and not on your host). Or to transfer the key by different channel, but ssh-copy-id will not help with that.

  • 1
    You are a life saving, thanks a lot, the only thing what I missed is that I had to set Password authentication to YES in the server not in my client! Thank a lot ! – Samirtow Mar 6 '16 at 17:25

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.