Wednesday, August 26, 2015

PuTTY Tutorial

Some of the step-by-step tutorials within SolarWinds Server & Application Monitor: Deployment and Administration make use of PuTTY, a handy open source SSH and telnet client. It is mentioned early on in the book that a PuTTY tutorial is outside of its scope. This article is intended to help bridge that gap, and provide some detail and tutorials on how to use PuTTY, for people new to the application.

What is PuTTY?
put·ty
ˈpədē/
noun
a soft, malleable, grayish-yellow paste, made from whiting and raw linseed oil, that hardens after a few hours and is used chiefly for sealing glass panes in wooden window frames.



No... that is not PuTTY, it is not a grayish-yellow paste. PuTTY is free, easy to use, and allows you to connect to anything which accepts SSH, Telnet, Rlogin, or Serial connections. You can use it to connect to most, if not all, of you networking gear, such as firewalls, routers, switches, wireless access points, etc. This also includes operating systems, such as Linux, Mac, iOS, Android, etc.

Microsoft recently announced (June 2015) that the PowerShell team is working to create a way to use PowerShell with SSH. This is very good news for Windows shops, but in coming years we may start to see that PuTTY is no longer the de facto standard for these Windows shops.

Downloading PuTTY
As mentioned above, PuTTY is freeware, you can download it here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

If you aren't sure which version to grab, for ease of use and sake of demonstration, just choose putty<version>-installer.exe.

Feeling generous? Need good karma? Donate to the PuTTY team of volunteers:
http://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-donations

Installing PuTTY
After downloading, you will of course need to launch the installation package.
  1. Browse to your download location and launch putty<version>-installer.exe.
  2. If you get a User Account Control prompt then select Yes.
  3. Select your preferred installation location.
  4. Leave the default selections and click Next a few times then Finish.
You can now find PuTTY in your Start Menu; I generally pin it to the desktop or taskbar.

Using PuTTY
Launch PuTTY by selecting it from your Start Menu, or by the desktop shortcut which you created.

After launching it you will be taken to the Sessions category. This is the default landing page, where you will spend most of your time. The first impression may be a little overwhelming as there are a number of different items to choose from within the Category pane to the left.

In most cases, all that you will need to do is simply leave everything alone, type a Host Name or an IP of a device or server, and then click the Open button. This works normally because SSH is selected by default and pointing to its default port of 22. This will not work for all devices or servers, as there are a number of different possibilities; for example, a device may be using a different port than 22 for SSH.

Logging
Covering logging first may feel a bit like putting the cart before the horse, but there's a reason for it. Understanding that PuTTY can and will log all of your Command Line Interface (CLI) output is very beneficial. It can save you time and money down the road. For example, you may eventually use vendor provided professional services to assist in the deployment and/or configuration for a device. Beforehand if you ask them to log their PuTTY output and send it to you afterwards then it can be an excellent reference tool later on down the road. In addition you may make a change to a server or device and months later forget how you did it or what you did.

The Logging category settings can be found under Session à Logging. From here you can choose where the log files will be stored, by default they are stored in the PuTTY installation directory.

Rather than listing what each option does, I will explain what works the best for me:
  1. Select Logging by selecting Session à Logging from the Category pane.
  2. Ensure All session output is selected.
  3. Ensure Always append to the end of it is selected.
  4. Leave the additional options as default.
  5. Change the default putty.log file name to putty-&h-&y&m&d-&t.log.
    • This will automatically prefix the host name you are connecting to, the year-month-day, and the time to the log file name.
  6. Select Session from the Category pane.
  7. Select Default Settings from Saved Sessions.
  8. Click the Save button to the right.

You can adjust the procedure to whatever suits your needs, the point is it is best to configure, or at least be aware of logging before you start diving into managing devices and servers with PuTTY.

Saved Sessions
As mentioned above, when launching PuTTY you are taken to the Sessions category. Towards the bottom right you will find Saved Sessions. These are essentially bookmarks which you can use to quickly connect to a device or server without remembering the Host Name or IP.

To begin with, you will only have a Default Settings saved session. If you make any changes to the categories, such as Window Appearance or Logging, and wish to retain the setting after restart, then make sure to go back to Session, select Default Settings, and click the Save button to the right. Likewise, if you create a custom Saved Session, and have loaded it by clicking the Load button, then make sure to select it, and then click the Save button after making any changes.

Create a PuTTY Saved Session for an SSH connection
As an example I will create a Saved Session to use for connecting to my FortiGate 60D firewall via SSH.
  1. Launch PuTTY.
  2. Enter FortiGate 60D in the field below Saved Sessions.
  3. Enter 192.168.1.99 in the field below Host Name (or IP address).
  4. Leave port 22 as is, since this is how the device is configured.
  5. Click the Save button to the right of your Saved Sessions.
    • Notice that the name FortiGate 60D still appears in the text field. This indicates that it is the currently loaded Saved Session.
You will now see the new Saved Session appear below Default Settings.


This creates a quick way to connect to the device or server, by simply Double Clicking the Saved Session, or selecting it and clicking the Open button.
Summary
I hope some of this has been useful for you, and I appreciate you taking the time to read it. The tutorials and information provided are intended to be a high level overview of PuTTY. If you have any questions regarding what was covered, or about anything which was not covered, then please leave a comment below and I will gladly make an update to the post.

No comments :

Post a Comment :