Can we generate a public key from a private key?
... for what PKE scheme?– user49075Sep 1, 2014 at 5:19
In RSA, and in normal implementations, yes you can.– AdiSep 1, 2014 at 5:48
3Hello and welcome to security.se. When asking question, please take the time to specify all relevant information. In it's current state, your question is impossible to answer.– StephaneSep 1, 2014 at 7:29
Also see: Given a private key, is it possible to derive its public key? on StackOverflow.– sleskeSep 1, 2014 at 9:09
By default, a user’s SSH keys are stored in that user’s
~/.ssh directory. You can check if your private key is in that directory by listing the contents:
$ cd ~/.ssh $ ls authorized_keys2 id_dsa known_hosts config id_dsa.pub
The private key is usually something like
id_rsa. To regenerate the public key part with just a private key, use the
-y switch to the
ssh-keygen application and write the output to a corresponding
ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub
From the 'man ssh-keygen' description:
-y This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.
If you don't know whether your private key is Digital Signature Algorithm (DSA) or Rivest Shamir Adleman (RSA), you will have to use the
ssh-keygen application with the
-f switch. Make sure the name of your new public key matches the name of your private key.