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

Server

Two distinct flavors of the Tectia server are available (as of Version 4.2). The full-featured Tectia Server (T) is intended for application tunneling, and supports extra functionality needed by Tectia Connector, while the slightly encumbered Tectia Server (A) is intended only for remote system administration. All the programs that make up these products are identical; the only difference is the license file that enables or disables the additional features.

16.11.1 Server Operation

The Tectia server is implemented by a program, ssh2master, that runs as a daemon and listens for incoming connections. A separate program, ssh2server, is run to handle each connection when it is accepted. The sftp server is implemented by the program sftp_server2.

Tip

If you run a Tectia server on a Windows system configured with a firewall, be sure to allow access to the port(s) used to accept SSH connections, typically port 22.

Stopping the ssh2master program doesn’t affect existing connections, since ssh2server continues to run. The Tectia server can even be restarted by a session that uses an SSH connection!

Normally, the Tectia server is run as a Windows service that is automatically started whenever the system boots. Several mechanisms can be used to start or stop the service manually:

  • Use the Tectia server administration program (discussed shortly).

  • Select either the Start Server or Stop Server item within the menu Start/Programs/SSH Tectia Server/Tools.

  • Access the Control Panel, and use the dialogs for Administrative Tools/Services to select the display name SSH Tectia Server, and then click Start, Stop, or Restart the service.

  • Run the start-ssh.bat or stop-ssh.bat scripts in the installation folder.

  • Start or stop the service using the command net start SSHSecureShell2Server or net stop SSHSecureShell2Server, respectively.

  • Run ssh2master -start or ssh2master -stop.

ssh2master also understands the options -install and -remove to add or delete the Tectia server from the list of Windows services.

In addition, ssh2master accepts a few options that we have discussed previously for sshd2 on Unix platforms:

-p port

Listen to the specified port. [5.3.3.1]

-f config-file

Use an alternate server configuration file. [5.2.1]

-d level

Run in debug mode, and specify the debug level. [5.9.2]

16.11.2 Server Configuration

The server’s configuration files are stored in the installation folder (nothing is stored in the Windows registry):

hostkey

Private host key (must be protected!)

hostkey.pub

Public host key

server_random_seed

Pool of random data

sshd2_config

Server configuration

sshd2_config has the same format as for Unix systems, and almost all of the keywords have exactly the same meaning for Windows, so we’ll just discuss the differences.

The server administration program, ssh2admin, also known as the Server Configuration tool (Figure 16-15), can display and change some keywords, but many features can be customized only by editing the file.

ssh2admin can be either run directly, or accessed by selecting the SSH Tectia Server Administration item within the menu Start/Programs/SSH Tectia Server. The Tools/View Configuration item displays the sshd2_config file in the Notepad editor.

Configuration changes take effect for each new session, as they are read by ssh2server. Only a few configuration keywords are used by ssh2master. If any of these are changed, the service should be restarted:

  • Port

  • ListenAddress

  • MaxConnections

FIPS mode is controlled by the FIPSmode keyword, with a value of yes or no (the default): [5.3.5]

    FIPSMode    yes

16.11.3 Commands and Interactive Sessions

When a command has been specified by an SSH client, it is run directly by the Tectia server. For commands that are built into the Windows command interpreter cmd.exe, specify cmd explicitly for the ssh command:

    $ ssh winserver.example.com cmd /c type readme.txt
Server configuration with ssh2admin

Figure 16-15. Server configuration with ssh2admin

Otherwise, if no command is given, then the server runs cmd.exe by default for the interactive session. An alternate program can be specified by the TerminalProvider keyword:

    # Tectia
    TerminalProvider    "some-other-cmd.exe"

This provides the same functionality as the login shell for Unix systems, except that it applies to all users. User-specific subconfiguration files can specify different programs for individual users. [11.6.2]

Users can run graphical applications from SSH sessions, but the applications have no access to the display, so this has limited usefulness. Full-screen text applications don’t work correctly, because they expect to run in a real console window, and the SSH connection doesn’t provide information about the window dimensions, etc.

By default, the Tectia server creates terminals for interactive sessions in a fully private window station. This is controlled by the PrivateWindowStation keyword:

    # Tectia
    PrivateWindowStation    yes

The DoubleBackSpace keyword copes with Japanese Windows systems, which require double backspaces to be sent by the server in response to single backspaces from the client, for each two-byte Japanese character. The value is either yes (to enable this behavior) or no (the default):

    # Tectia
    DoubleBackSpace     yes

Child processes that are launched from SSH sessions are not automatically terminated when the session ends. This could be construed as a bug or a feature, depending on the circumstances: beware.

The user profile folder is used as the home folder for commands and interactive sessions.

16.11.4 Authentication

Windows passwords are used for password authentication. The password authentication method is always required for domain user accounts. Public-key authentication works only for local user accounts, not domain user accounts.

The %D pattern for the UserConfigDirectory keyword refers to the user profile folder. [5.3.1.5] The user configuration folder contains the authorization file and public keys.

Tip

The default value for UserConfigDirectory is %D/.ssh2, which works and is consistent with the Unix location. However, it is strange from a Windows perspective, and different from all of the other Tectia programs, which use the Application Data\SSH subfolder within the user profile folder.

16.11.5 Access Control

Accounts that use the SSH server for logins must possess the right to “log on locally.” This is disabled by default on some servers, such as domain controllers. Keywords like PermitRootLogin that refer to the Unix superuser affect any Windows accounts with administrative privileges.

In the server configuration, domain user accounts should be specified as domain/user (with a forward slash). The usual Windows backslash separator cannot be used.

Windows groups are not supported by the server, so keywords and values that refer to groups must not appear in the configuration files.

16.11.6 Forwarding

The Tectia server supports only TCP port forwarding on Windows, and enforces the restriction that only privileged users can use privileged port numbers (less than 1024).[182] X forwarding and agent forwarding are not supported.

16.11.7 SFTP Server

To support SFTP, the Tectia server configuration must include the sftp subsystem definition:

    Subsystem-sftp      "sftp_server2.exe"

No internal implementation is built into the SSH server, as it is for the Tectia servers on Unix systems.

The SFTP server restricts access to a set of folders. This is controlled by the Sftp-DirList keyword:

    # Tectia
    Sftp-DirList    "HOME=%D, SCRATCH=S:\scratch\%U"

The value is a comma-separated list (with optional whitespace), where each element has the format virtual=real. Virtual folder names are arbitrary, and are presented to the SFTP clients. These are mapped to the specified real folders on the server. The folder names can contain the patterns %D and %U, representing the user profile folder and the username, respectively. The default value is HOME=%D.

A set of administrative (or power) users can be defined to use an alternate list of folders:

    # Tectia
    Sftp-AdminUsers     "administrator, backup.*, rebecca"
    Sftp-AdminDirList   "HOME=%D, BACKUP=Z:\backup, C:=C:, D:=D:"

The value for Sftp-AdminUsers is a comma-separated list (with optional whitespace) of username patterns. By default, only the administrator account is included.

The Sftp-AdminDirList value has the same format as for Sftp-DirList. The default is HOME=%D, C:=C:, D:=D:.

SFTP sessions start in a home folder, which is specified by the Sftp-Home keyword:

    # Tectia
    Sftp-Home           "S:\sftp\%U"

The SFTP home folder must be accessible, according to Sftp-DirList or Sftp-AdminDirList. The folder can use the same patterns, %D and %U. The default is %D (the user profile folder).

16.11.8 Logging and Debugging

The server records log messages in the Windows event log, instead of using the standards syslog service found on Unix systems. The event log can be viewed using the Tectia server administration program, or using the Control Panel, by selecting Administrative Tools/Event Viewer.

The verbosity of the messages is controlled by the EventLogFilter keyword:

    # Tectia
    EventLogFilter      error, warning

Values are a comma-separated list (with optional whitespace) consisting of one or more of the following levels:

error

Serious problems that prevent operations from completing

warning

Problems that allow operations to continue

information

Normal, successful events

Note that the higher levels do not include the lower levels, as they do for syslog on Unix systems. Each Windows event log level must be specified explicitly.

The SFTP server’s log messages are controlled by a separate keyword, SftpLogCategory, that specifies the kinds of messages that are sent to the event log:

    # Tectia
    SftpLogCategory     31

The numeric value is the sum of any of the following:

  • 16 = user login/logout (the default)

  • 8 = folder listings

  • 4 = modifications

  • 2 = uploads

  • 1 = downloads

The ssh2admin program provides more convenient checkboxes to specify the value for SftpLogCategory.

The ssh2master -d option works the same way as it does for sshd2 on Unix systems to enable debug mode and specify the debug log level: [5.9.2]

    # Tectia
    ssh2master -d4

Debug output is written to the console window by default, but this can be redirected to a file:

    # Tectia
    ssh2master -d4 2> debug.txt

The scripts debug-ssh.bat and debug-ssh-file.bat run ssh2master with debug level 4, as shown earlier. In addition, the debug-ssh-file.bat script redirects output to the file sshd2_debug_output.txt in the installation folder, and then displays the file in the Notepad editor after the server exits. These scripts can also be run by selecting the items Troubleshoot Server or Troubleshoot Server and Save Debug Output from the menu Start/Programs/SSH Tectia Server/Tools.



[182] Windows does not normally distinguish privileged ports from higher-numbered ports.