How to Connect to a Linux Server with SSH, Using PuTTY – Pageant – Windows
I’m playing with my new VPS hosting & trying doing some tasks through SSH; but before being able to do this, I had to setup my SSH connection.
1. Generate SSH Certificate
a. 1st thing you need to do is to create a SSH certificate in your server, I did this in my cPanel / WHM. Just browse around to find SSH icon, then the Generate a New Key link. You will be asked to give your new key a name & password, then Key Type & Key Size (I used the default values here DSA / 1024, you may experiment with other values). Next click on Generate Key.
b. Once created, you have to click the Manage Authorizations link & then the Authorize button. Then back to the previous page, & now under Private Keys (not public!), click the View/Download Key link.
c. Under Private SSH Key MyKeyName (PuTTY PPK format), enter the password you created in Step a. & hit Convert. You will be sent to a page where the converted key is displayed in a text area (lines of random characters). Copy all the content of the text area then paste it in Notepad, next, save it in a file with a ppk extension (for example mykey.ppk). Put the key preferably in a new folder & call it SSH for example.
2. Setup PuTTY Under Your Local Windows System
a. Download putty.exe & pageant.exe (we will use this last later) from the official site Chiark or a trusted software download site.
b. Put both programs in the folder called SSH in which we put the PPK key previously. You could also create shortcuts for them to put in your Start Menu.
c. Now open PuTTY & enter your Host Name or Server IP in the field made for that. Then in the side menu go to Connection > Data & under Login details type the username that will be used to connect, in my server it’s root (try it).
d. From the side menu go back to Session, enter a name in the Saved Sessions field & click on the Save button.
3. Add Your Key to Pageant & Connect to the Server
a. Open Pageant, it will show as an icon in the Notification Area right of your Task Bar. Right-click on it to display its menu.
b. Click on Add Key to open the key we downloaded in Step 1. c. above. You will be asked to enter a password, enter the one we created in Step 1. a..
c. Right-click again on the Pageant icon & now go to Saved Sessions & open the session we created in Step 2. d.. Now you should see your connection starting
• Everytime you open Pageant, you will need again to load the key before opening your session.
• If like me you try to Copy/Paste data by doing Ctrl + c & Ctrl + v inside the black connection window of PuTTY, it doesn’t work that way, it seems those commands are sent to the server & may have some nasty effects!
– To copy, just select text using the mouse, & it will automatically be copied to the Clipboard.
– To past, a simple Right-Click is enough.