Putty SSH Key Management
So in order for someone to give you SSH access to a linux machine you usually have to give them a public key. To get a public key you need to generate a private key first.
-
If you have never created a private .ppk key before please go to section 1.1 to create a public & private key pair. It’s important that you don’t share your private key. Your public key can be shared without any issues. You only need one private key to SSH to multiple machines.
-
If you already have a private .ppk key and need to know your public key go to section 1.2.
1.0 Best Practices
Please only create one key per physical machine. They key should stay on your physical machine at all times and not be copied anywhere. A single key on your laptop should be able to SSH to multiple machines it’s allowed access to.
If you need ssh access on a another machine like a Desktop, don’t copy the SSH key from your laptop. Instead, create a new key for your Desktop and send the public key to the owner of the machine so they can grant ssh access to your public key.
1.1 Generating Public Private Key Pair
-
Download putty somewhere on the Internet and install it. Personally I use ninite.com, check PuTTY, download, then run the installer.
-
After putty is installed search for PutTTYgen in Windows and run it.
3. Select Key > SSH-2 RSA-key.
4. Then click “Generate”. Once you do it will ask you to make random mouse movements to help it make it extra random.
5. Then copy the public key as shown in the above picture. Send this to the person who administers the server so they can add it to that server.
6. Now click “Save private key” and save it somewhere on your computer. In my example I keep mine in C:\Keys\ but you can save it anywhere you want.
Connecting to the Server via SSH
1. Launch PuTTY. Type in the Hostname or IP Address of the server you want to connect to. As for the port you can usually leave it as the default 22 unless specified otherwise by your administrator.
2. After that expand SSH and select Auth as shown in the picture below. Then browse and find the privatekey you saved earlier in step 5 above.
3. (Optional) Now select Data on the left side as shown below.
4. (Optional) Here you may enter in the username you will be using to login. This step is entirely optional as you can manually enter in your username when PuTTY prompts you to isntead.
5. Now scroll up and go back to “Session” on the navigation.
6. Finally we are going to store the session on PuTTY. Just type in a name for your session then click Save.
7. Once it is saved you can just double click on the saved session to launch it.
1.2 Getting your public key from your private key in PuttyGen
If you need to get your public key from your private .ppk key. Launch PuttyGen. After that click on “Load”. Then browse and choose your private .ppk key. After that your public key should appear under the Key box. You want to copy the contents here and give it to the person that needs to give you SSH access. A quick video tutorial of this is shown right below:
Please note you can use this same private key for SSH on multiple machines. That means you can give away this same public key as many times as you want. Your private key on the other hand should not be shared.
2.0 Optional: Keepass + KeeAgent for Windows
Demo of quick SSH access with Keepass Password Manager. Private key is encrypted in Keepass Database.
How to setup KeeAgent + Keepass at 24m25s: https://www.youtube.com/watch?v=e6G8zHZlhv8&t=24m25s
3.1 For Linux Admins
Add a user “sammy” as root.
adduser sammy
usermod -aG sudo sammy
Login as sammy then
cd ~
mkdir .ssh
cd .ssh
nano authorized_keys
paste the public key to authorize logins into authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAiWiY4iNpiqs9cfmTMSdsjNvvBldgAwd9NF+XWAmfGXSA43NTNGV59cyQ+3sMeI6zaVWSyb6zFB0ux/xyjSFRJbxLEHswyEoEvTz0z4iPIBHdBL2JECqhO6KyOGrI5tC7Yb93C0iI+NLppbAwKMWA3TxOdYpbNMo1lmHcc1ce+pZr5CgvKYgn342vtsKOnb6ruaCEr5UEwQ38vPQl5WX6xJBTnm4tmv9uccA8kUSdTkbKzc+B8a1Q3bPTQBCQbt1GKLgZTEQjXEz0wwHKb5EHwXa5nFy9Nts/+/bUAqBL+ra32pVn/vvMLCKP3+3ZIpFqNfjlzEk4r06EC/zyQe2PKQ== rsa-key-20200610
save and exit.








