David Stevens
David Stevens

Reputation: 865

Duplicating an ssh private key file

I have a private key under ~/.ssh/id_rsa. Running ssh-keygen -l -f ~/.ssh/id_rsa confirms that the key is valid.

I'm trying to create another file containing this key. For example,

cp ~/.ssh/id_rsa ~/.ssh/id_rsa.dupe
chmod 0400 ~/.ssh/id_rsa (to make permissions the same for both files)

But when I run ssh-keygen -l -f ~/.ssh/id_rsa.dupe, I get ~/.ssh/id_rsa.dupe is not a key file.

Upvotes: 0

Views: 788

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295500

This is expected behavior. ssh-keygen -l refers to a public key file, per its documentation:

  -l     Show fingerprint of specified public key file.

If you want to generate a private key and generate a public key, you can use -y to do that:

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

Upvotes: 3

Related Questions