ssh-copy-id no identities found error

UnixSshSsh Keys

Unix Problem Overview


I have few client systems where I need to push the ssh key and login from my server without authentication prompts.

First, on the server, I created ssh key as below which was successful

]# ssh-keygen -t rsa -N "" -f my.key

Second, tried copying the pub key but fails with no identity error. Am i doing a wrong step here?

]# ssh-copy-id my.key.pub 10.10.1.1
/usr/bin/ssh-copy-id: ERROR: No identities found

Unix Solutions


Solution 1 - Unix

You need to use the -i flag:

ssh-copy-id -i my.key.pub 10.10.1.1

From the man page:

>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

Solution 2 - Unix

Generating ssh keys on the client solved it for me

$ ssh-keygen -t rsa

Solution 3 - Unix

Run following command

# ssh-add

If it gives following error: Could not open a connection to your authentication agent

To remove this error, Run following command:

# eval `ssh-agent`

Solution 4 - Unix

The simplest way is to:

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."

Solution 5 - Unix

The ssh-copy-id is not able to locate the id_rsa.pub file that is generated by ssh-keygen in your system, Use the following command to complete:

  1. find the path of the .pub file: locate *.pub
  2. copy the path (ex: /home/user_name/.ssh/id_rsa.pub) and run the following command: ssh-copy-id -i /home/user_name/.ssh/id_rsa.pub hostname

Solution 6 - Unix

You need to specify the key by using -i option.

ssh-copy-id -i your_public_key user@host

Thanks.

Solution 7 - Unix

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.

Hope this helps anyone.

Solution 8 - Unix

came up across this one, on an existing account with private key I copied manually from elsewhere. so the error is because the public key is missing

so simply generate one from private

 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

Solution 9 - Unix

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.

Solution 10 - Unix

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.

Solution 11 - Unix

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.

Solution 12 - Unix

ssh-keygen

then

sudo service ssh restart

after this, you should be able to use ssh-copy-id without having to provide any additional commands

Solution 13 - Unix

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.

Solution 14 - Unix

Use simple ssh-keyscan hostname to find if key(s) exists on both sites:

ssh-keyscan rc1.localdomain
[or@rc2 ~]$ ssh-keyscan rc1
# rc1 SSH-2.0-OpenSSH_5.3
rc1 ssh-rsa AAAAB3NzaC1yc2EAAAABI.......==

ssh-keyscan rc2.localdomain
[or@rc2 ~]$ ssh-keyscan rc2
# rac2 SSH-2.0-OpenSSH_5.3
rac2 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAys7kG6pNiC.......==

Solution 15 - Unix

In my case it was the missing .pub extension of a key. I pasted it from clipboard and saved as mykey. The following command returned described error:

ssh-copy-id -i mykey localhost

After renaming it with mv mykey mykey.pub, works correctly.

ssh-copy-id -i mykey.pub localhost

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3331975View Question on Stackoverflow
Solution 1 - UnixJosh JollyView Answer on Stackoverflow
Solution 2 - UnixendumiuzView Answer on Stackoverflow
Solution 3 - UnixSMSMView Answer on Stackoverflow
Solution 4 - UnixTúlio RicardoView Answer on Stackoverflow
Solution 5 - UnixGuruView Answer on Stackoverflow
Solution 6 - UnixAshish BhosleView Answer on Stackoverflow
Solution 7 - Unixn1c0View Answer on Stackoverflow
Solution 8 - UnixDan KuidaView Answer on Stackoverflow
Solution 9 - UnixBYRAKUR SURESH BABUView Answer on Stackoverflow
Solution 10 - UnixMark MooreView Answer on Stackoverflow
Solution 11 - UnixAsociaView Answer on Stackoverflow
Solution 12 - UnixAmir KhalilView Answer on Stackoverflow
Solution 13 - UnixVignesh MenonView Answer on Stackoverflow
Solution 14 - UnixHankerPLView Answer on Stackoverflow
Solution 15 - UnixfraczView Answer on Stackoverflow