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 whi
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
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
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:
locate *.pub
ssh-copy-id -i /home/user_name/.ssh/id_rsa.pub hostname
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."
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.......==