I am creating an encryption strategy for a lab project and want to know if there exists the capability to create a public key from just the private key?
Otherwise, can the public key only be created at the same time as the private key from some key generator?
P.S. A quick google didnt really help.
The public key is derived from the private key at generation time, and with the private key at any point in the future it is possible to re-derive the public key easily. It is not feasible to go the other way. Given a public key it is not easy to derive the private key.
To generate an SSH private/public key pair for your use, you can use the ssh-keygen command-line utility. You can run the ssh-keygen command from the command line to generate an SSH private/public key pair. If you are using Windows, by default you may not have access to the ssh-keygen command.
Depends on the algorithm. With RSA, you cannot, with EC you can. However, the public key is usually always stored together with the private key (not the other way around, though, of course), so this is not really a problem (if you have the private key, the same file also includes the public key).
Command line comparison to show there is no difference between a public RSA key and an extracted key if you ignore whitespace.
Generate public private key pairing under home directory with no passphrase and no coment.
ssh-keygen -t rsa -f ~/id_rsa -N '' -C ""
Generate public key into file 'extracted_public_key'
ssh-keygen -y -f '/home/vagrant/id_rsa' > extracted_public_key
Diff public key with 'extracted_public_key' file ignoring white space.
diff -b id_rsa.pub extracted_public_key
Ignoring whitespace at the end of id_rsa.pub there is no difference between a public key and an extracted key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With