ssh-keygen can generate files in three formats:
- OpenSSH own format (RFC4716, the default),
- PKCS8 and
- PEM format.
You can distinguish them by the first line of the private key:
- if it says
"-----BEGIN OPENSSH PRIVATE KEY-----", it's RFC4716,
- if it says
"-----BEGIN RSA PRIVATE KEY-----", it is PEM,
- and if it is just
"-----BEGIN PRIVATE KEY-----" it is PKCS8.
In all cases, the public key looks the same. It is also able to convert freely between those formats.
What you use in PowerShell is OpenSSH. You can verify that by running
ssh -V. It should work with keys in any of these formats out of the box.
To convert a file generated by the
ssh-keygen into Putty's ppk format, use
puttygen. Or, you may generate the key with
puttygen and it is able to convert it into the OpenSSH format.
The public key contains three parts, "type key comment", of which the last is optional and can be changed freely. It can be used in the
authorized_keys file to tag keys (e.g. to explain where the corresponding private key is or whose key it is). Other parts should be copied verbatim. Notice, that the public key always contained in a single line, and it should be appended as an individual line to the
If you are already able to ssh to the target host using any authentication mechanism, try
ssh-copy-id target-host, which will create the
.ssh/authorized_keys with correct privileges if it doesn't exist and add private key there, or it will append the key if file exists but the key is not in the file. The other way to build such a file is something like
cat id_rsa.pub >> authorized_keys.
puttyneeds a specific format for its '.ppk' files. It looks something like: pastebin.com/EjQ5DA5R, containing private and public key in a fixed format. You may create such a file with
puttygen, and then convert to openSSH format afterwards. I do not know anything about powerShell, unfortunately. Edit: Updated link.