Ssh-copy-id 没有找到标识错误

在很少的客户机系统中,我需要在没有身份验证提示的情况下推送 ssh 密钥并从服务器登录。

首先,在服务器上,我创建了下面这样的 ssh 密钥,它是成功的

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

第二,尝试复制酒吧钥匙,但失败,没有身份错误。我在这里做了一个错误的步骤?

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

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

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`

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

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.

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

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

ssh-copy-id -i your_public_key user@host

Thanks.

Generating ssh keys on the client solved it for me

$ ssh-keygen -t rsa

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

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.

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

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.

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

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.

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