If the -i option is given then the identity file (defaults to ~/.ssh/id_rsa.pub) is used, regardless of whether there are any keys in your ssh-agent. Otherwise, if this: ssh-add -L provides any output, it uses that in preference to the identity file
Old post but I came up with this problem today, ended up googling and had found myself here. I had figured it out on my own but thought I'd share my issue & solution in my case to help out anyone else who may have the same issue.
Issue:
[root@centos [username]]# ssh-keygen -t rsa
Enter file in which to save the key (/root/.ssh/id_rsa):I HAD JUST HIT ENTER
/usr/bin/ssh-copy-id: ERROR: No identities found
Solution:
Enter file in which to save the key (/root/.ssh/id_rsa): **/home/[username]/id_rsa**
Be sure if you are doing this as root you are coping the key into the user directory you wish to login with. NOT the root user directory.
I was sshing into the machine when performing this operation, so I guess ssh-copy-id just point to the dir you are logged in as by default.
ssh-keygen
[enter]
[enter]
[enter]
cd ~/.ssh
ssh-copy-id -i id_rsa.pub USERNAME@SERVERTARGET
Att:
Its very very simple.
In manual of "ss-keygen" explains:
"DESCRIPTION
ssh-keygen generates, manages and converts authentication keys for ssh(1). ssh-keygen can create RSA keys for use by SSH protocol version 1 and
DSA, ECDSA or RSA keys for use by SSH protocol version 2. The type of key to be generated is specified with the -t option. If invoked without
any arguments, ssh-keygen will generate an RSA key for use in SSH protocol 2 connections."
I had faced this problem today while setting up ssh between name node and data node in fully distributed mode between two VMs in CentOS.
The problem was faced because I ran the below command from data node instead of name node
ssh-copy-id -i /home/hduser/.ssh/id_ras.pub hduser@HadoopBox2
Since the public key file did not exist in data node it threw the error.
Actually issues in one of Ubuntu machine is ssh-keygen command was not run properly. I tried running again and navigated into /home/user1/.ssh and able to see id_rsa and id_rsa.pub keys. then tried command ssh-copy-id and it was working fine.
FWIW, the -i option was a red herring for me. ssh-copy-id will use ~/.ssh/id_rsa.pub by default.
What was keeping it from working for me was the permissions on the ~ directory, the ~/.ssh directory, and the ~/.ssh/authorized_keys file on the remote computer.
All three need to be set with chmod 755 ~ ~/.ssh ~/.ssh/authorized_keys, then ssh-copy-id your-remote-server.com will work.
I had the same issue. The problem was my ~/.ssh/id_rsa.pub file being empty. I overwritten it somehow while messing around with my ssh config. The problem is solved after correcting the file.