I want to create private and public key pairs to be used for SSH authentication.
I can't figure out the difference between this:
openssl genrsa -out MyPrivateKey 4096 openssl rsa -in MyPrivateKey -pubout -out MyPublicKey
which first creates a private RSA key and then derives the public key from it, or:
ssh-keygen -b 4096 -t rsa -f MyFancyKey
which creates a private RSA key in the file 'MyFancyKey' and the corresponding public key in 'MyFancyKey.pub'.
The structure for the private keys seems somewhat similar, although the one created with
openssl begins with:
-----BEGIN RSA PRIVATE KEY-----
And the one from
ssh-keygen begins with:
-----BEGIN OPENSSH PRIVATE KEY-----
Is there a fundamental difference between these two kinds of keys?
Then the corresponding public keys, the one from
-----BEGIN PUBLIC KEY----- ...base64 encoded... -----BEGIN PUBLIC KEY-----
While the one from
ssh-keygen just contains one line:
ssh-rsa XXXXXX...base64 encoded...XXXXX Rocketnuts@Rocketnuts-MBP.my.networkname
Are these essentially the same kind of data but formatted differently? Or are they really incompatible?
I'm trying to fully understand how all this works in relation to SSH. For example why is my username, my computer name, and my local network name in that key, isn't it typically supposed to be used to access SSH on other computers? With my username on that computer, not my own.