Search code examples
azurepowershellsshpublic-key-encryptionssh-keygen

How using ssh-keygen generate public key that would have ---- BEGIN SSH2 PUBLIC KEY ---- at the top?


I am using PowerShell and generate keys with the following command

ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f $HOME/.ssh/id_rsa

Keys get generated however public key is a single line and does not have ---- BEGIN SSH2 PUBLIC KEY ---- at the top and ---- END SSH2 PUBLIC KEY ---- at the end which are required when starting Azure instance with SSH public key admin account.

I could just add those lines manually I guess, but I have a feeling since key generation is a commonly done thing, there should be a way to do it via command line.

How using ssh-keygen generate a public key that would have ---- BEGIN SSH2 PUBLIC KEY ---- at the top?


Solution

  • Figured out myself

    I had to add -e (export) option

    Full command looks following:

    ssh-keygen -b 2048 -C "email@gmail.com" -f $HOME/.ssh/id -e