First of all this is not a question ultimately about copying a public SSH key to a server's authorized list (like many of the search results I looked through), I assure you.
I have an SSH keypair that I generated on my laptop, however I wiped the hard drive to install a different Linux distro (Xbuntu 18.04.1 LTS). I have the public and private keys and the keyphrase saved on a online password manager.
The public key is in the form:
ssh-rsa (base64 key) user@hostnameThe private key is in the form:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,(hexadecimal number)
(base64 key)
-----END RSA PRIVATE KEY-----How can I import these into my new OS install? Either via GUI or CLI?
1 Answer
Unless I am misunderstanding the question, the solution is to add them to your user’s ~/.ssh/ directory on the new machine.
First, create that ~/.ssh/ directory — if it doesn’t somehow already exist — like this:
mkdir -p ~/.ssh/Now copy and paste that private key to the file id_rsa in ~/.ssh/ like this; using nano as an example but otherwise use whatever editor you like to use.
nano ~/.ssh/id_rsaPaste it in there and save it.
For the public key, do something similar but for the file id_rsa.pub like this:
nano ~/.ssh/id_rsa.pubNow with that done, be sure the permissions for the ~/.ssh/ directory are 700 like this:
chmod 700 ~/.ssh/And finally set the permissions for the key files themselves like this:
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pubThe keys should now be set an usable. Attempt to connect to whatever host you use them with and you should be a prompt for the passphrase. Enter it and et voilà! It should be recognized and used.
1