user3331975
user3331975

Reputation: 2805

ssh-copy-id no identities found error

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

Upvotes: 120

Views: 304658

Answers (18)

JeanDeaux615
JeanDeaux615

Reputation: 1

Ok this how I fixed mine! All the documentation says how both ssh-copy-id and ssh-keygen use as default ~/.ssh but that incorrect, ssh-key-gen prompts you to use /root/.ssh/id_rsa so what I did was:

cd ~   # to get to the home directory
 
pwd    # to ascertain where I was
 
ls -al # to see what was in my default home directory 

Noticing that there was no /.ssh I then went to /root/.ssh and copied the .ssh directory and its contents to /

Now with /.ssh present and all my corresponding files in it I was able to ssh in, get prompted for password, and informed that you are trying to setup passwordless login. You can then ssh into your server without being prompted

Upvotes: 0

watchpoints
watchpoints

Reputation: 69

ssh-keygen
ssh-copy-id [email protected] 

Upvotes: 1

HotFix
HotFix

Reputation: 335

Might sound stupid, but for some reason the file I needed to copy did not have the correct name. It was called id_rsa.pu. Be sure the file name is exactly id_rsa.pub or tell ssh-copy-id to pickup on a specific identity file with ssh-copy-id -i path/to/identity_file.pub

Upvotes: 0

Amir Khalil
Amir Khalil

Reputation: 307

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

Upvotes: 1

sahinakkaya
sahinakkaya

Reputation: 6056

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.

Upvotes: 1

Mark Moore
Mark Moore

Reputation: 395

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.

Upvotes: 2

HankerPL
HankerPL

Reputation: 21

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

Upvotes: 0

BYRAKUR SURESH BABU
BYRAKUR SURESH BABU

Reputation: 289

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.

Upvotes: 4

Dan Kuida
Dan Kuida

Reputation: 1057

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

Upvotes: 6

Vignesh Menon
Vignesh Menon

Reputation: 9

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.

Upvotes: 0

n1c0
n1c0

Reputation: 89

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.

Upvotes: 7

Túlio Ricardo
Túlio Ricardo

Reputation: 379

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

Upvotes: 27

Guru
Guru

Reputation: 2857

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

Upvotes: 10

endumiuz
endumiuz

Reputation: 981

Generating ssh keys on the client solved it for me

$ ssh-keygen -t rsa

Upvotes: 88

Ashish Bhosle
Ashish Bhosle

Reputation: 657

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

ssh-copy-id -i your_public_key user@host

Thanks.

Upvotes: 8

fracz
fracz

Reputation: 21249

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

Upvotes: -3

SMSM
SMSM

Reputation: 1519

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`

Upvotes: 34

Josh Jolly
Josh Jolly

Reputation: 11786

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

Upvotes: 91

Related Questions