Tag: ssh-keygen

  • How to create public key from SSH private key?

    How to create public key from SSH private key?

    Lost SSH public key, don’t worry, you can generate it from your private key file. If you have an SSH private key, you can generate the public key using the ssh-keygen command.

    ssh-keygen -f PRIVATE_KEY_HERE -y
    

    -y option will read a private OpenSSH format file and print an OpenSSH public key to stdout.
    -f specifies the location of your private key file.

    Example

    ssh-keygen generate public key

    If you have passphrase set, ssh-keygen will prompt for the password.

    root@ee:~/my-key# ssh-keygen -f boby.pem -y
    Enter passphrase: 
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAEF0dvZOurGujYDucipjXjM2mHE+BFO91HGZKRU/RkpS1ZDzQiA164yev9eoxZRTHHnxb46TWfoLeHy8nEwa+BkijxBnaCkU2GlC9oFInSnCHLUuas87c/EBJ4KTcjfoZ+Ocxjn0MP0T4YsSzwIU1v8deH7t7/zQJW733DyVls0wDlRTgHGzlldBnrzF9dSNMRMXQuhl+rcQtIapfrjVPZGlkQfh7yCUJf2oK10l9I01zrITdwlzqao1732AtdXt6GlHz6016mWfzjLGX/RGnkj1+5XEYYa9IIQRN7IXhNwcgzDybI0OLsioeKapSprWhs9Ftx14csyC/7PXHuf+50vDOs26NM3BsFuwUB6R0Tkm88uJeDj/HAwlDlowFk8GIYU4WIZr85g1TUeV0eXwjFc3wEgLBO7b6VbBXDRpnhOec8Lnmpj1BUK4Bp4z27PuxhGj5CUnc096ZDOit3EzOeOfAzanFrtlT+td/GmS0GJ0hhBs+6u9aLdiKE28Oies= root@ee
    root@ee:~/my-key# 
    

    See SSH, ssh-keygen

  • ssh-keygen

    To generate SSH key, run

    ssh-keygen -t ed25519

    If you need RSA key, run

    ssh-keygen -b 4096

    To create an SSH key in the current folder, run

    ssh-keygen -b 4096 -N "" -f NAME_OF_KEY

    This will create 2 files in the current directory. The “-N” option is for keyphrase. With -N “”, it won’t ask you for kayphrase.

    ssh-keygen

    See Change SSH Key Passphrase

  • Change SSH Key Passphrase

    To change SSH key passphrase, run

    ssh-keygen -p -f ~/.ssh/id_rsa
    

    Example

    root@ok:~/.ssh# ssh-keygen -p -f ~/.ssh/id_rsa
    Enter new passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved with the new passphrase.
    root@ok:~/.ssh# 
    

    See ssh-keygen