How to make ssh-copy-id without a headache

If you, like I today, cannot perform a passwordless login via ssh to a remote Linux server after copying a public key to the server with ssh-copy-id command, please check if the key is actually presents among other authorized keys on the server. I found that sometimes it is not.

$ cat .ssh/authorized_keys
The agent has no identities.

To fix the problem just add the -i argument like below:

$ ssh-copy-id -i user@server.tld