Você está na página 1de 4

PuTTY: A Free SSH Client

Yeo Eng Hee

(HPC,Computer Centre)

Introduction

Secure Shell (or SSH) is, according to Wikipedia, “a cryptographic network protocol for secure data
communication, remote shell services or command execution and other secure network services between two
networked computers that it connects via a secure channel over an insecure network: a server and a client
(running SSH server and SSH client programs, respectively).”

PuTTY is a free tool available on the internet that uses SSH protocol for secure data communication between a
server and a client.

Besides using PuTTY for secure terminal login, do you know that it can also help to transfer files securely
between your personal computer and HPC directories?

PuTTY Software Package

PuTTY is more than just the single executable (putty.exe) that most of you are familiar with. The rest of the
executables in the package are listed below:

 PuTTY (the Telnet and SSH client itself)

 PSCP (an SCP client i.e. command-line secure file copy)

 PSFTP (an SFTP client i.e. general file transfer sessions much like FTP)

 PuTTYtel (a Telnet-only client)

 Plink (a command-line interface to the PuTTY back ends)

 Pageant (an SSH authentication agent for PuTTY, PSCP, PSFTP, and Plink)

 PuTTYgen (an RSA and DSA key generation utility).

If you have only the putty.exe file, it is now time to discard that and install the full package from:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Choose the “Windows Installer for everything except PuTTYtel”.

After you have run the installer and installed the package of executables, you’ll see the following items in your
Windows Start menu:

1
Setting up the SSH key for PuTTY

Most HPC users may not know this, but they have been using SSH for many of their HPC jobs, especially if they
have been using MPI. In fact, their accounts already have a key-pair generated specifically for their use. PuTTY
can make use of this key-pair, and the steps are as follows:

1. Start up PuTTYgen (PuTTY Key Generator) by clicking on the icon in the start menu.
2. The PuTTY Key Generator window will pop-up. Select Conversions in the menu.

3. Choose Import key and navigate to U:\.ssh\ directory.

Note: This directory should be mapped to your account when you registered to use HPC resources).

4. Select the file called id_rsa and save it without a passphrase. Choose to save it as id_rsa.ppk, which PuTTY
will recognize and use later.

Once you have created a key from your HPC account, you can make use of it to automatically login to your HPC
session via PuTTY. To be able to use this key automatically, set up the PuTTY SSH authentication agent, Pageant
as follows:

1. Click on Start menu -> All Programs and right-click on Startup to open it.
2. With the Startup window open, click on Start menu again, navigate to the PuTTY folder and drag the
Pageant icon to the Startup window while holding down the Shift and Control keys. This will create a
shortcut in the Startup menu that will automatically run Pageant whenever you login to your account.
2
Note: If you encounter network slowness during startup and your PC failed to read the key file, you may
need to place the .ppk file in a local harddisk instead.

3. Right click on the Pageant shortcut that you have just created and modify the Target string by appending
U:\.ssh\id_rsa.ppk to the pageant.exe command as shown:

4. Test the Pageant setup by logging out and logging into your PC account again.
5. You should see the Pageant icon in your taskbar when you login:

Using PuTTY

Once the Pageant is set up to run in your account, you can automatically access your HPC account using the
PuTTY suite of programs without having to type in a password. The best way to illustrate this is to try out some
examples on the Windows command prompt (make sure that you have set the path to the PuTTY executables in
your local PC’s PATH environment variable):

1. This command opens a terminal console via PuTTY:


putty -ssh [username]@atlas4-c01

3
2. This command transfers a file from the user’s HPC home directory to the C:\ drive on your PC:
pscp [username]@atlas4-c01:myfile.txt C:\
3. This command transfers files from a user’s /hpctmp/[username]/ directory (assuming it exists and belongs
to username) to the C:\Temp\ folder:
pscp -batch /hpctmp/[username]/* c:\temp\

For details on the use of PuTTY commands, please read the PuTTY manual found in the PuTTY folder in the Start
menu.

Tips for Efficient File Transfers

Besides terminal login sessions, most of the usage of PuTTY or SSH client is for file transfers. Here are some tips
that users should keep in mind when doing file transfers across the network, especially when transferring big
files or large numbers of files:

 Use the command line to transfer large files. Some graphical SSH clients generate large overheads when
doing file transfers. We have found that graphical clients take longer to transfer files as a result.
 Do not transfer whole directories by specifying the directory in the pscp command. Instead, use the ‘*’
wildcard as in the third example in the previous section. Alternatively, zip up the directory and compress it
into a single .zip file before transferring the file. In general, text files have a high compression ratio, and is
best transferred in this manner.
 Transfer only the files you need. Some applications only require the results files to be transferred. By
managing the files to be transferred, usage of the network bandwidth can be reduced for the benefit of all
users.
 For power users, put the command line into a DOS batch script and automate the file transfers. This is
especially useful if you do the same file transfers regularly.

Você também pode gostar