Connecting To Server With Putty Using SSH Keys & Port Forwarding

September 14, 2010

Quick and dirty tutorial to connecting to a remote server with ssh keys and putty.

Firstly you need to download putty and puttygen which can be found:-

Here - Putty Client
Here - PuTTYgen

Yes they are both the same page, you will find the download links for both here.

Once you have downloaded both the clients you will need to first generate yourself a key using the puttygen and then save it out to a file in a location you will easily be able to remember. Remember you need to generate a public and private key, but the private is the one of most use to you.

Im going to largely breeze over adding your ssh key to the server, as you should really know how to do this already before attempting to use putty with ssh keys and port forwarding.

Open up putty, enter the host as whatever it needs to be either an ip address or a host name like and specify the port as 22 if it isn't already.

Then head down on the left hand menu to the SSH list which will probably be shut, click the plus to expand the list and head to the AUTH tab. Here enter the user you want to auto login with and specify the path to your key using the browse file function.

If all is correct head back to the "session" tab and move to the right hand side, and save your settings under any name you like, this is to ensure that you can pick up where you left off when returning to the same connection again.

Now you have done that hit open and you should with any luck either be presented with a enter passphrase for key authorisation, enter that and youll be in.

Port Forwarding Mysql From Remote To Local

Should you like us sometimes want to dev locally to a remote database, Putty can be used to tunnel a mysql connection from a remote server to your local mysql port. To do this in most cases simply forward the following or well at least for me.

Navigate to the following.
Connection -> SSH -> Tunnels -> Options Controlling Port Forwarding

L 3307 port destination to
the remote database.

Add that in, head back to session save it and then open it and wollah you should now be able to dev locally to the remote database, by forwarding mysql to your local ports.

This is just a quick and dirty tutorial and not meant to be a fully comprehensive guide, however if theres something you want to know I may be able to help, so leave a comment.

About me

Hello! I'm David Heward, how are you going? I'm a Senior Devops/Build Engineer, specialising in AWS & Cloud Automation. Based in London. Strong 10+ year background in Software development. Have a read of my blog. Have a look at some of my working projects. Contact me at @davehewy or on Linkedin.