Last updated on May 31st, 2022 at 07:27 pm

While using ssh-copy-id command sometimes you should be getting an error

/usr/bin/ssh-copy-id: ERROR: No identities found

Solution 1

This could be because id_rsa.pub didn’t got created in the path /home/USERID/.ssh/ or incorrect permission. Take a backup of the .ssh directory , Delete the .ssh directory and try recreating it again.

But if everything looks good and still you are seeing this error. Then, follow the next solution

Solution 2

Issue command, in my case the script is residing in /usr/bin/ssh-copy-id

which ssh-copy-id
more /usr/bin/ssh-copy-id

Find out what the variable ID_FILE is referring to. It will be sometimes referred as identity.pub instead of id_rsa.pub. If that is the case please rename the variable ID_FILE to point to id_rsa.pub
The other option is(without modifying /usr/bin/ssh-copy-id ) before issuing ssh-copy-id command, copy id_rsa.pub to identity.pub then run ssh-copy-id. This should normally fix the issue.

cp -p id_rsa.pub identity.pub
ssh-copy-id <SOMEID>@<TARGET_SERVER>

Solution 3

In latest versions of linux you would see a line inside /usr/bin/ssh-copy-id which points to most_recent_id variable

most_recent_id="$(cd "$HOME" ; ls -t .ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)"

If we try to run just the above command you will see that it is looking for id_rsa.pub file like shown below

root@production-server:~# cd "$HOME" ; ls -t .ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1
.ssh/id_rsa.pub
root@production-server:~#

Make sure that the file referred using variable most_recent_id within the ssh-copy-id script is present in your .ssh directory.

This is one of the best working solutions you can find on the internet.

Fixed some bugs and added extra solutions on May 31st 2022

Leave a Reply

Your email address will not be published. Required fields are marked *