Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more how to generate public/private key pair with like below in ios, swift. Oct 12, 2015 In order to import the key from the certificate using CryptoImportExportManager, you just need to call its importExportManager.importPublicKeyReferenceFromDERCertificate method: You can, of course, extract your public keys from the certificate using OpenSSL, to have a more manageable public-private key files.
Lets say you have a private/public key pair that you use to login to your server via SSH and you lose the public key, either it was deleted or corrupt and you don’t want to have to regenerate a new pair what options do you have? In this post I will demonstrate how to regenerate a public key from the corresponding private key that you still have.
Generate public key and store into a file
It is a simple one liner command to generate a public key from a private key, so lets say our private key is named ‘[email protected]’ and we want to generate the public key and name it ‘authorized_keys’. Below is the command to do this.
Now we will need to take our authorized_keys file and store it on the server, if we can currently login via SSH to our server we can use rsync over ssh to securely copy the public key to the server, Although this key is displayed to anyone who attempts to login to your server it is smart to use SSH or another secure method to copy it up to the server to ensure that the key is not tampered with while it is being transmitted.
Below is an example using rsync to copy the authorized keys file to its destination on the server and removing it from your local computer.