Table of Contents for
SSH, The Secure Shell: The Definitive Guide, 2nd Edition

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition SSH, The Secure Shell: The Definitive Guide, 2nd Edition by Robert G. Byrnes Published by O'Reilly Media, Inc., 2005
  1. Cover
  2. SSH, the Secure Shell, 2nd Edition
  3. Preface
  4. Protect Your Network with SSH
  5. Intended Audience
  6. Reading This Book
  7. Our Approach
  8. Which Chapters Are for You?
  9. Supported Platforms
  10. Disclaimers
  11. Conventions Used in This Book
  12. Comments and Questions
  13. Safari Enabled
  14. Acknowledgments
  15. 1. Introduction to SSH
  16. What Is SSH?
  17. What SSH Is Not
  18. The SSH Protocol
  19. Overview of SSH Features
  20. History of SSH
  21. Related Technologies
  22. Summary
  23. 2. Basic Client Use
  24. A Running Example
  25. Remote Terminal Sessions with ssh
  26. Adding Complexity to the Example
  27. Authentication by Cryptographic Key
  28. The SSH Agent
  29. Connecting Without a Password or Passphrase
  30. Miscellaneous Clients
  31. Summary
  32. 3. Inside SSH
  33. Overview of Features
  34. A Cryptography Primer
  35. The Architecture of an SSH System
  36. Inside SSH-2
  37. Inside SSH-1
  38. Implementation Issues
  39. SSH and File Transfers (scp and sftp)
  40. Algorithms Used by SSH
  41. Threats SSH Can Counter
  42. Threats SSH Doesn’t Prevent
  43. Threats Caused by SSH
  44. Summary
  45. 4. Installation and Compile-Time Configuration
  46. Overview
  47. Installing OpenSSH
  48. Installing Tectia
  49. Software Inventory
  50. Replacing r-Commands with SSH
  51. Summary
  52. 5. Serverwide Configuration
  53. Running the Server
  54. Server Configuration: An Overview
  55. Getting Ready: Initial Setup
  56. Authentication: Verifying Identities
  57. Access Control: Letting People In
  58. User Logins and Accounts
  59. Forwarding
  60. Subsystems
  61. Logging and Debugging
  62. Compatibility Between SSH-1 and SSH-2 Servers
  63. Summary
  64. 6. Key Management and Agents
  65. What Is an Identity?
  66. Creating an Identity
  67. SSH Agents
  68. Multiple Identities
  69. PGP Authentication in Tectia
  70. Tectia External Keys
  71. Summary
  72. 7. Advanced Client Use
  73. How to Configure Clients
  74. Precedence
  75. Introduction to Verbose Mode
  76. Client Configuration in Depth
  77. Secure Copy with scp
  78. Secure, Interactive Copy with sftp
  79. Summary
  80. 8. Per-Account Server Configuration
  81. Limits of This Technique
  82. Public-Key-Based Configuration
  83. Hostbased Access Control
  84. The User rc File
  85. Summary
  86. 9. Port Forwarding and X Forwarding
  87. What Is Forwarding?
  88. Port Forwarding
  89. Dynamic Port Forwarding
  90. X Forwarding
  91. Forwarding Security: TCP-Wrappers and libwrap
  92. Summary
  93. 10. A Recommended Setup
  94. The Basics
  95. Compile-Time Configuration
  96. Serverwide Configuration
  97. Per-Account Configuration
  98. Key Management
  99. Client Configuration
  100. Remote Home Directories (NFS, AFS)
  101. Summary
  102. 11. Case Studies
  103. Unattended SSH: Batch or cron Jobs
  104. FTP and SSH
  105. Pine, IMAP, and SSH
  106. Connecting Through a Gateway Host
  107. Scalable Authentication for SSH
  108. Tectia Extensions to Server Configuration Files
  109. Tectia Plugins
  110. 12. Troubleshooting and FAQ
  111. Debug Messages: Your First Line of Defense
  112. Problems and Solutions
  113. Other SSH Resources
  114. 13. Overview of Other Implementations
  115. Common Features
  116. Covered Products
  117. Other SSH Products
  118. 14. OpenSSH for Windows
  119. Installation
  120. Using the SSH Clients
  121. Setting Up the SSH Server
  122. Public-Key Authentication
  123. Troubleshooting
  124. Summary
  125. 15. OpenSSH for Macintosh
  126. Using the SSH Clients
  127. Using the OpenSSH Server
  128. 16. Tectia for Windows
  129. Obtaining and Installing
  130. Basic Client Use
  131. Key Management
  132. Accession Lite
  133. Advanced Client Use
  134. Port Forwarding
  135. Connector
  136. File Transfers
  137. Command-Line Programs
  138. Troubleshooting
  139. Server
  140. 17. SecureCRT and SecureFX for Windows
  141. Obtaining and Installing
  142. Basic Client Use
  143. Key Management
  144. Advanced Client Use
  145. Forwarding
  146. Command-Line Client Programs
  147. File Transfer
  148. Troubleshooting
  149. VShell
  150. Summary
  151. 18. PuTTY for Windows
  152. Obtaining and Installing
  153. Basic Client Use
  154. File Transfer
  155. Key Management
  156. Advanced Client Use
  157. Forwarding
  158. Summary
  159. A. OpenSSH 4.0 New Features
  160. Server Features: sshd
  161. Client Features: ssh, scp, and sftp
  162. ssh-keygen
  163. B. Tectia Manpage for sshregex
  164. Regex Syntax: Egrep Patterns
  165. Regex Syntax: ZSH_FILEGLOB (or Traditional) Patterns
  166. Character Sets for Egrep and ZSH_FILEGLOB
  167. Regex Syntax: SSH Patterns
  168. Authors
  169. See Also
  170. C. Tectia Module Names for Debugging
  171. D. SSH-1 Features of OpenSSH and Tectia
  172. OpenSSH Features
  173. Tectia Features
  174. E. SSH Quick Reference
  175. Legend
  176. sshd Options
  177. sshd Keywords
  178. ssh Options
  179. scp Options
  180. ssh and scp Keywords
  181. ssh-keygen Options
  182. ssh-agent Options
  183. ssh-add Options
  184. Identity and Authorization Files, OpenSSH
  185. Identity and Authorization Files, Tectia
  186. Environment Variables
  187. Index
  188. Index
  189. Index
  190. Index
  191. Index
  192. Index
  193. Index
  194. Index
  195. Index
  196. Index
  197. Index
  198. Index
  199. Index
  200. Index
  201. Index
  202. Index
  203. Index
  204. Index
  205. Index
  206. Index
  207. Index
  208. Index
  209. Index
  210. Index
  211. Index
  212. Index
  213. About the Authors
  214. Colophon
  215. Copyright

Advanced Client Use

PuTTY is simple to use in its most basic form. Nevertheless, its clients have many options that are worth trying out. We will cover the ones relating to SSH. Other terminal-related features, like settings for the window, keyboard, and mouse, we encourage you to explore on your own.

18.5.1 Saved Sessions

If you have a habit of connecting to the same remote machines often, set up a Saved Session, which remembers the settings for that connection so that you can reuse them. This is similar to the OpenSSH and Tectia feature of configuration files, but with a GUI. [7.1.2] Simply configure PuTTY the way you like it, then save that configuration under a name, such as “My Favorite Settings” or “office.”

When you create and name a Saved Session, it becomes available not only to PuTTY, but also to the other programs in PuTTY’s suite, such as PSCP and Plink. Just provide the saved session’s name in place of a hostname. For example, if you created a Saved Session called “office” to stand for employer.example.com, you could run:

    C:\> plink office

and it will connect to employer.example.com.

Saved Sessions are stored in the Windows registry under the key \HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions.

18.5.2 Host Keys

Like other SSH implementations, PuTTY records the host keys of SSH servers it encounters. They are stored in the Windows registry under the key \HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys.

18.5.3 Choosing a Protocol Version

We always recommend you use the SSH-2 protocol, since it is more secure and robust than the original SSH-1. Nevertheless, PuTTY does support both protocols, and you can choose your preferred protocol on the PuTTY Configuration dialog, under Connection/SSH. The choices are:

1 only

Require SSH-1, or else fail.

1

Try SSH-1 first, then SSH-2.

2

Try SSH-2 first, then SSH-1.

2 only

Require SSH-2, or else fail (recommended).

With Plink, you can force the protocol version with the -1 (SSH-1 only) and -2 (SSH-2) options:

    C:\> plink -2 smith@server.example.com

18.5.4 TCP/IP Settings

SSH uses TCP/IP as its transport mechanism, and PuTTY gives you control over some TCP-related settings.

18.5.4.1 Selecting a remote port

SSH servers almost always run on TCP port 22, but if you encounter a nonstandard server, you can choose a port in the PuTTY Configuration dialog, under Connection. Locate the Port value and fill it in.

With Plink, just specify the -P option to set the port number:

    C:\> plink -P 12345 smith@server.example.com

18.5.4.2 Keepalive messages

SSH clients can optionally send TCP keepalive messages to an SSH server to recognize when a connection has failed. [7.4.5.4] If the client detects a lack of responses to these messages, it shuts down the connection. You can enable or disable this feature in the PuTTY Configuration dialog, under Connection.

18.5.4.3 The Nagle Algorithm

TCP/IP has a feature called the Nagle Algorithm, which is designed to reduce the number of TCP segments sent with very small amounts of data (e.g., 1 byte), usually as part of an interactive terminal session. This can affect performance over wide-area networks. [7.4.5.5] PuTTY lets you enable or disable the Nagle Algorithm in the PuTTY Configuration dialog, under Connection.

18.5.5 Pseudo-Terminal Allocation

SSH clients allocate a pseudo-terminal on the server machine: a software abstraction representing a computer terminal. [7.4.6.5] PuTTY does this by default, but you can prevent this in the PuTTY Configuration dialog, under Connection/SSH.

Because PuTTY is designed as a terminal client, which is interactive, you generally can leave this setting alone. But if you’re using PuTTY noninteractively, say, only to set up port forwarding—you don’t strictly need a pseudo-terminal. If you’re using Plink, you can disable pseudo-terminal allocation with the -T option or leave it enabled with -t.

18.5.6 Proxies and SOCKS

PuTTY supports SOCKS, an application-layer network proxying system supported by various SSH implementations. [7.4.7] You can enable it in the PuTTY Configuration dialog, under Connection/Proxy.

18.5.7 Encryption Algorithms

On the Connection/SSH section of the PuTTY Configuration dialog, you can choose the encryption algorithms (ciphers) acceptable to the client. [7.4.9] Any algorithms appearing below the line “--warn below here--” will cause PuTTY to display a warning before they are used.

For most people, the defaults are fine. But if, say, a security hole were found in one of the algorithms (say, Blowfish), you could move it below the line, and PuTTY will warn before using it.

18.5.8 Authentication

PuTTY supports the following authentication types: password, public-key, challenge-response (a.k.a. keyboard-interactive), and TIS. [7.4.13] Password authentication works by default. Public-key authentication requires you to set up a key, as we’ve seen. [2.4] Challenge-response authentication is enabled in the PuTTY Configuration dialog, under Connection/SSH/Auth. [5.4.5]

TIS authentication is uncommon: it authenticates users via the Gauntlet firewall toolkit from Trusted Information Systems. It works only for the SSH-1 protocol so we recommend against using it. That being said, it is enabled in the PuTTY Configuration dialog, under Connection/SSH/Auth.

18.5.9 Compression

The data flowing between the SSH client and server may optionally be compressed to save bandwidth. [7.4.14] To enable compression, open the PuTTY Configuration dialog and look under Connection/SSH. If you’re using Plink, add the -C option to enable compression:

    C:\> plink -C smith@server.example.com

18.5.10 Logging and Debugging

If you’re having a connection problem with PuTTY, you can capture the session data in a file. Open the PuTTY Configuration dialog and look under Session/Logging. Here you select the file to receive the data, and four different settings:

Logging completely turned off

As it says, do no logging.

Log printable output only

This simply captures the text of your terminal session, and is not very useful for debugging.

Log all session output

This captures not only the text of your session, but also any nonprinting control characters. This is useful for debugging terminal emulation problems, e.g., if your favorite text editor isn’t behaving when viewed through PuTTY.

Log SSH packet data

This is the big one: the actual SSH data, unencrypted, that passes over the connection. It appears in hexadecimal and ASCII, annotated with high-level information such as “Doing Diffie-Hellman group exchange” and “Access denied.” If you’re debugging an SSH problem, this is the logging you need. However, it’s not very user-friendly: you’ll need substantial knowledge of the SSH protocol to figure out what’s going on.

Warning

If you select “Log SSH packet data,” always select “Omit known password fields” as well. Otherwise, sensitive data like passwords will be captured in the log file, which is a security risk if the log file is read or stolen by a hostile third party.

If you’re using Plink, you can display diagnostic information with the -v option:

    C:\> plink -v smith@server.example.com
    Server version: SSH-1.99-OpenSSH_3.8.1p1
    We claim version: SSH-2.0-PuTTY-Release-0.56
    Using SSH protocol version 2
    Doing Diffie-Hellman group exchange
    Doing Diffie-Hellman key exchange
    Host key fingerprint is:
    ssh-dss 1024 80:de:c6:fa:f7:82:4f:c7:c4:8c:1f:6f:d4:40:4b:0e
    Initialised AES-256 client->server encryption
    Initialised AES-256 server->client encryption
    ...

18.5.11 Batch Jobs

SSH can be used within batch jobs to secure their communications. [11.1] With PuTTY, batch jobs are most easily done with Plink and its -batch option:

    C:\> plink -batch smith@server.example.com my-job

The -batch option suppresses all user prompts. But wait: just because you’ve disabled prompts doesn’t automatically authenticate you. You’ll also need to set up passwordless authentication. Otherwise, you’ll simply fail to authenticate, prompts or no.