So generated my public and private key pair in Windows but I have to use my keys in my Linux, specifically Ubuntu, to ssh from there.
How do I do that? I have my private and public keys with me.
So I know that I have to put ’em in the ~/.ssh/authorized_keys but authorized_keys dir does not exist and I am not sure if I should just literally copy the keys there. I thought SSH is for security so it probably won’t be that straightforward.
By the combined power of Google, Reddit and StackOverflow, I solved this mess!
In my Linux machine:
mkdir ~/.ssh || true chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
In my Windows machine:
1. Using PuttyGen, click Load and load existing private key
2. Conversions->Export OpenSSH and export your private key
3. Copy private key to ~/.ssh/id_rsa
Back to my Linux machine:
4. Create the RFC 4716 version of the public key using ssh-keygen
ssh-keygen -e -f ~/.ssh/id_rsa > ~/.ssh/id_rsa_com.pub
After #4, I encountered an error that says:
WARNING: UNPROTECTED PRIVATE KEY FILE!
Permissions 0744 for ‘/home/katpadi/.ssh/id_rsa’ are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /home/katpadi/.ssh/id_rsa
To fix: I reset the permissions by doing:
sudo chmod 600 ~/.ssh/id_rsa
5. The last step is to convert the RFC 4716 version of the public key to the OpenSSH format:
ssh-keygen -i -f ~/.ssh/id_rsa_com.pub > ~/.ssh/id_rsa.pub
Hooray!
I can now ssh -l katpadi somethingsomething.blah.com happily ever after in my Linux machine.