Simple ssh-copy-id question

Soldato
Joined
18 May 2010
Posts
22,372
Location
London
I always find this so hard. I've managed it using this guide but my question is, why did he use the mykey rather than the mykey.pub file, when the author says NEVER copy the private keys?

Isn't the mykey the private key?

:confused:

Is it because although you specify the private key it actually copies the public?
 
Last edited:
Soldato
Joined
3 Oct 2013
Posts
3,622
Is this for ssh login to remote ? if so,

Easy way, I'm going to presume you have done ssh-keygen already.

When run you should have two files, one called id_rsa and one called id_rsa.pub in .ssh config dir. DO NOT GIVE OUT THE id_rsa file/contents

On the remote server create a file authorised_keys in .ssh of the user.

Copy and paste the contents of id_rsa.pub into said file.

To use do

Code:
ssh -l "username" -k "servername"

HTH
 
Soldato
OP
Joined
18 May 2010
Posts
22,372
Location
London
Cool. I get that.

I have it working, by following the guide above but confused.

I'm confused as two guides both say the same thing.

If you look at the guide I posed above the ssh-copy-id command he seems to be specifying the key which doesn't have the .pub extension as the key to copy.

Either this is wrong, or the ssh-copy-id command actually copies the .pub key of the private key you specify.

Very confusing for inexperienced admins like me. :o


---

According to this, the -i defaults to the .pub file.
 
Last edited:
Soldato
Joined
3 Oct 2013
Posts
3,622
Cool, glad you got it sorted.
If in doubt if you do man "prog_name" or -h will generally give you a run down on whats what.

To be honest, never tried the copy-id, seems long winded to me. I've always thought it is a lot easier to do it like I posted .

This is the problem with guides, what works well for one doesn't necessarily mean for you/someone else.
 
Soldato
Joined
18 Oct 2002
Posts
7,020
Location
Melksham
Always read the man page :p

But yeah, if the identity file given doesn't end in .pub it adds it, so in the example "mykey" and "mykey.pub" end up being the same thing, even though it's a little odd to see. I'd argue the guides should probably explicitly use the .pub version, or at least describe why it's 'ok'
 
Back
Top Bottom