In my work, I often log on to multiple servers using a brilliant tool : putty. This perfect in (almost) every way program has one major drawback – no tabs (like firefox), so to not go mad from the amount of open windows, they must be periodically shut down. Re-logging in, searching for 20 character password invented by admins of is wasting a lot of time. Every time. Therefore, I have some tips on how deal with it. I will describe my configuration – it may be useful to someone – it saves me a lot of time every day. So one by one …

Generating the key

From program’s official website (link) download (except the putty of course) two programs: Pageant and PuTTYgen. The first is used to authenticate on the server and the other to generate the key, which will be used..

After downloading, run PuTTYgen and generate a key in a few simple steps – you have to do it only once:

  1. In the middle of the interface is a button „Generate”. After pressing ityou should move the mouse until the bar disappears – this will generate a key pair: public and private.

    Okno programu

  2. In the key passphrase field, type Your password for opening the key. This password will be used to open the key and load it into memory the second program. Choose your password properly: your private key will give a potential attacker access to all servers, in which the key is used!In the confirmation field, type the password again.
  3. The „Save public key” saves us a the public part of key – it will be pre-loaded onto the server in the next step.
  4. The „Save private key” stores a private key, which will be used by our putty.
  5. Content in the top section of the program – a strange and unrecognizable string of characters – you can select with the mouse and copy it to clipboard – this will speed up the next points.

Preparing the server

This step may require the server administrator intervention – if it is configured in some other way than the default.

On the server you want to log in automatically,’s authorized_keys file in the folder .ssh in your home directory.

For this file, insert a public key, which has just been generated. Open the file with your favorite editor – mcedit in mine case – and paste the generated key (should be in the clipboard according to point 5 of the previous section).

After making sure that at the end of the file is a newline character, close editor and save changes.

Repeat operations on all servers to which you want to have automatic login.

Preparation of client – the key loading

For the downloaded Pageant create a shortcut on the desktop with any name. Then edit its properties by adding additional parameters.

?adowanie klucza

In the box with the path to the program you need to add the path to the key you want to load automatically. You can specify additional keys, if you already have a key provided by the administrators or you want to automatically log on to the machine using a different private key. If your key is stored in a location that has spaces in the path you must include the quotation marks in every path – the path to the program separately and individually the path to the key

You hould place this shortcut in the Startup folder that is located in the Start Menu. Now, after each boot you will be prompted to enter a password from section 1. It’s the only time in which You enter your password.

Preparation of client – putty configuration

The default configuration should be sufficient to login without a password. Just make sure that checkbox „Attempt authentication using Pageant” in the SSH Connection Auth the settings is checked. For me it is selected, but I am using this method on all my machines for a long time and I do not know default settings.

After clicking Open a connection to the selected server will be opened … and you will be prompted for a user name:) by typing the name You will be automatically logged. Is it possible to omit the question about user name? It is!! :) We go back to the putty settings, select the profile and in the section Data Connection type your user name in field Auto-login username. After clicking Open You will be automatically logged.

In the event of a problem with logging, on top of the screen putty should display a message indicating whether there was even an attempt to log on with a key. If this message does not appear, it means that the server is not properly configured and administrator intervention is required. In another case, a descriptive message should say what is wrong – then you must to check this guide again, or seek help online.

Additional tricks

A shortcut to putty with Profile autoloading

Putty accepts command line parameters. By creating several shortcuts to it and adding parameter -load „profile_name_from_putty_settings” You can automatically load a profile and with the technique described in this guid to log in to the server without password.

Login to next servers within an existing session

Sometimes during a connection to the server you want to execute some command on another remote server. Also in this case – if we have entered your public key in target server – you can skip authentication. In the Connection \ SSH Auth settings in putty select the option „Allow agent forwarding”. Each subsequent connection will be authenticated by the agent. This option is useful also in the scenario where only one server at a given location is visible from the outside and is used as a gateway to another servers.

Minimizing application to the notification area – the system tray

If you want putty to remain open and minimized to the notification area, there are two solutions:

  1. Using a general system utility that can hide any program
  2. Using a modified version of Putty – PuTTY Tray – available at: http://haanstra.eu/putty/

The modified version allows minimization, and includes several modifications that might appeal to some:

  1. Automatic retry the connection after disconnection
  2. Automatic connection after returning from standby
  3. Easy access to the option „Always on top”
  4. Ability to activate the transparency of window
  5. The ability to store profiles in files – ideal for saving profilesfor example on USB memory

Global hotkeys to run putty

Using PuTTY Session Manager is possible to set global hotkeys (Win + 0 .. 9) to run specific sessions. The program allows also::

  1. Categorize saved sessions in a tree
  2. Window transparency
  3. Window always on top
  4. Integration with WinSCP – putty sessions are available in WinSCP
  5. Saved session synchronization between machines – either by moving file by hand or by exposing a file on the network
  6. Global hotkeys
    1. New connection – no session selected, the default putty screen
    2. Minimize putty windows
    3. Open selected session, by pressing the Win+0..9
  7. Autoload Pageant with keys

Changing the default settings for putty

To change the default settings – for example, change the encoding to utf-8 – start putty and do not choose any profile, just make changes and return to the home page, select the profile „Default settings” and click Save. Unfortunately, this does not work on saved sessions. When you create new profile putty copies current settings so that all fields have a current value.

So far it all. If you know any tricks to please share them in comments.

 

18 września 2011 19:57 Grzegorz Drozd Brak komentarzy Komentuj Kategorie: Narz?dzia, Praca

Bądź uprzejma(y).

Możesz używać następujących tagów HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Twój adres e-mail nie będzie wyświetlony.

Twój adres e-mail nie będzie przekazany nikomu.

Wszystkie komentarze są moderowane.