Monday, May 12, 2014

Generate SSH (.ppk) keys and connect user account with Putty on Windows

Step 1:  Download “puttygen.exe” and run to generate public/private ssh (.ppk) key file.

Step 2:  Launch the “puttygen” on windows, keep all default settings:



Step 3:  Now click on “Generate” button to create key.
               
Note: Move your mouse around within the blank space during the key generation process.

Step 4:  Once the generator is complete, you will see a windows with your new public key and key fingerprint:



Step 5: You can change the “Key comment” like hostname or any other remarks as you want

Step 6:  if you want, you can fill the “key passphrase” and “confirm passphrase” fields.

Step 7:  Select the contents of public key in that large text field and copy the entire content (CTRL+C) into clipboard.

Note:    Do not quit puttygen.exe at this time.

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAhCdDMhGHdaw1uj9MH2xCB4jktwIgm4Al7S8rxvovMJBAuFKkMDd0vW5gpurUAB0PEPkxh6QFoBNazvio7Q03f90tSP9qpJMGwZid9hJEElplW8p43D3DdxXykLays2M8V2viYGLbiXvAbOECzwD4IaviOpylX0PaFznSR4ssXd0= my-workstation-home

Step 8:  Now open up Notepad and paste (CTRL + V) the content into a new file. Save file with “.txt” extension, like publickey.txt.

Note: The public key is what will be put on your server.

Step 9:  Go back to PuttyGen and click on the “Save private key” button on the main window under the “Save the generated key” section. You can call that file “privatekey” or “privatekey.ppk”

Note: The private key remains private and should never be given to anyone. It does not go on your site account; it stays on your workstation.  Keep this file safe or else you will need to re-do everything if the private key is ever lost.

Step 10: Now you have a public and private key file saved on your workstation. You can quit out of PuTTYGen now.

Step 11: Login to site via SSH, you can install your public key: Category à Connection àSSH à Auth à click on browse button and find the private key generated previously and click the “Open” button to load it.

Step 12:  In Category section à select Session” à fill hostname / ip-address à click on “Open” button and then you will get prompt for username and password.

Step 13:  Type the following command at the prompt and press enter key:
                $ mkdir ~/.ssh; touch ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys

Step 14: open the “authorized_keys” file in command line and use nano here:
$ nano ~/.ssh/authorized_keys

Note :  Once you have made your changes, you can exit “nano” by pressing “Ctrl+X”, then press “Y”, and finally “enter” to confirm the overwrite/filename.

Step 15:  After entering passphrase you should be logged into your account via SSH
Authenticating with public key "my-workstation-home"
Passphrase for key "my-workstation-home":