My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UsingPuTTY  
Tips and tricks for SSH/PuTTY
Updated Dec 28, 2011 by sstrickr...@gmail.com

Introduction

PuTTY comes with a great session management, where you can save attributes of connections (e.g. ssh key, username, port). This page describes how to make use of it - partly in form of a FAQ. For this to work, you need the PuTTY.exe-application.

How to use sessions

One special "session" is the Default Settings session, where you can set default values for all new connections (e.g. a key, a default username, enable compression, force SSH version 2 or change the default port and so on).

You can also save settings for (single) ssh connections as sessions. Take one server where the ssh server only listens on a different port, then you can set up all settings and save it to e.g. "SERVERNAME". Now you can access this saved settings by starting PuTTY and double clicking "SERVERNAME" in the saved sessions list OR, when using TortoiseGit, plink or other putty applications, the entered servername (e.g. git@SERVERNAME:/test.git) will be matched against the saved sessions list and if found, the settings of the saved session are used.

Session names do not need to be the exact servername, you can also use different names, like "SERVERNAME1" or "SERVERNAME-adminkey" (e.g. git@SERVERNAME-adminkey:/test.git) if you want to use different keys with the same username on one server. This way it is also possible to have a saved session called "test.com", but when accessed a connection to example.com (saved hostname) is established.

FAQ and examples section

This section is based on the descriptions above and will bring some examples for the usage with TortoiseGit (and plink).

The examples assume that you want to clone git@example.com:/test.git.

How to use a default key for all SSH connections

Start PuTTY, go to Connection->SSH->Auth and select your key. Then go to Session, select Default Settings and hit Save.

Now PuTTY (TortoiseGit and plink) will try to use this key for all new connections (no need to configure it in TortoiseGit). If the PuTTY agent is running, putty and plink try to use an already loaded key, but will ask for the password themselves (as a fallback).

How to connect to a SSH server on a different port

All connections to a server should use the different port

Start PuTTY, fill in the servername (example.com here) in the Host Name-field and into the Saved Sessions field. Change the port number to the number you need and click on Save. Now, when TortoiseGit/plink uses this servername the port is automatically loaded from the session.

One a special connection should use a different port

Start PuTTY, fill in the servername (example.com here) in the Host Name-field and put the servername followed by e.g. a number into the Saved Sessions field (e.g. example.com1 or whatever you like). Change the port number to the number you need for this connection and click on Save.

Now, when you want to use this saved session use example.com1 as the servername: Clone git@example.com1:/test.git. Plink detects that this is a saved session and loads the correct servername and port from the session.

You can create several sessions for a server with different session names, but make sure you do not use the servername (example.com here) as the exact session name, otherwise these settings will be the default ones if you try to connect to the server (example.com).

How to use two different ssh keys for the same user on the same host

Start PuTTY, fill in the servername (example.com here) in the Host Name-field and put the servername followed by e.g. a number into the Saved Sessions field (e.g. example.com1 or whatever you like). Go to Connection->SSH->Auth and select the key which should be used for this connection. Now go back to Session and click on Save.

Now, when you want to use this saved session use example.com1 as the servername: Clone git@example.com1:/test.git. Plink detects that this is a saved session and loads the correct servername and ssh key from the session.


Sign in to add a comment
Powered by Google Project Hosting