can not setup passwordless ssh using key by MANUALLY COPY public key to server


  • firstly, i got a new ubuntu 20.04 server with a password
  • I’m using OpenSSH client on Windows 10
  • I want to do passwordless login, then I
    • ssh to server using passwords,
    • manually create ~/.ssh /authorized_keys and open it in vim
    • copy&paste my public key content from my to ssh window.
    • exit that ssh session and try to passwordless login,
    • failed
  • (some more tries and many headbang)
  • I install Git Bash On Windows, then run ssh-copy-id and got another identical line in authorized_keys on the server
  • now I could successfully passwordless login to server

Why this happen? Does ssh-copy-id do more thing than just insert a line in (server) ~/.ssh/authorized_keys?

enter image description here

Asked By: Luke


Look at both entries in your .ssh/authorized_keys file. The first entry starts with sh-rsa, whereas your second starts with ssh-rsa. That’s most likely the problem. So when you copy/pasted your public key, you simply made a typo.

Answered By: mpboden
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.