Can we generate a public key from a private key?
closed as unclear what you're asking by Gilles, Rory Alsop♦ Sep 1 '14 at 15:30
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
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.