and a client connection and disconnection appear as:log: Server listening on port 22. log: Generating 768 bit RSA key. log: RSA key generation complete.
sshd1 permits logging to be controlled in three ways:log: Connection from 128.11.22.33 port 1022 log: Rhosts with RSA host authentication accepted for smith, smith on myhost.net log: Closing connection to 128.11.22.33
Fascist Logging mode is controlled by the FascistLogging keyword in the server configuration file, given an argument of yes or no (the default):[74]debug: Client protocol version 1.5; client software version 1.2.26 debug: Sent 768 bit public key and 1024 bit host key. debug: Encryption type: idea debug: Received session key; encryption turned on.
[74]But it's barely supported in SSH2, as we'll see. [Section 5.8.2.5, "SSH2 Fascist Logging mode"]
# SSH1 (and SSH2) FascistLogging yes
Debug mode prints the same diagnostic messages as Fascist Logging mode but also echoes them to standard error. For example, a server run in Debug mode on TCP port 9999 produces diagnostic output like the following:# SSH1, OpenSSH $ sshd -d
The server then waits in the foreground for connections. When one arrives, the server prints:# SSH1, OpenSSH $ sshd -d -p 9999 debug: sshd version 1.2.26 [sparc-sun-solaris2.5.1] debug: Initializing random number generator; seed file /etc/ssh_random_seed log: Server listening on port 9999. log: Generating 768 bit RSA key. Generating p: .....++ (distance 100) Generating q: .............++ (distance 122) Computing the keys... Testing the keys... Key generation complete. log: RSA key generation complete.
When the client exits, the server exits as well, since (as the preceding messages show) the server doesn't fork subprocesses while running in Debug mode but handles a single connection within the one process:debug: Server will not fork when running in debugging mode. log: Connection from 128.11.22.33 port 1022 debug: Client protocol version 1.5; client software version 1.2.26 debug: Sent 768 bit public key and 1024 bit host key. debug: Encryption type: idea debug: Received session key; encryption turned on. debug: Installing crc compensation attack detector. debug: Attempting authentication for smith. debug: Trying rhosts with RSA host authentication for smith debug: Rhosts RSA authentication: canonical host myhost.net log: Rhosts with RSA host authentication accepted for smith, smith on myhost.net debug: Allocating pty. debug: Forking shell. debug: Entering interactive session.
Debug mode has the following features beyond those of Fascist Logging mode:debug: Received SIGCHLD. debug: End of interactive session; stdin 13, stdout (read 1244, sent 1244), stderr 0 bytes. debug: pty_cleanup_proc called debug: Command exited with status 0. debug: Received exit confirmation. log: Closing connection to 128.11.22.33
$ ssh -p 9999 myserver.net [...login output begins...] Environment: HOME=/home/smith USER=smith LOGNAME=smith PATH=/bin:/usr/bin:/usr/ucb MAIL=/var/mail/smith SHELL=/usr/bin/ksh TZ=US/Eastern HZ=100 SSH_CLIENT=128.11.22.33 1022 9999 SSH_TTY=/dev/pts/3 TERM=vt220 REMOTEUSER=smith [...login output continues...]
Quiet | Debug | Fascist Logging | Results |
---|---|---|---|
No | No | No | Default logging (syslog); no "debug:" messages |
No | No | Yes | Fascist Logging mode (syslog) |
No | Yes | Yes/No | Debug mode (syslog, stderr) |
Yes | No | No | Log fatal errors only (syslog) |
Yes | No | Yes | Log fatal errors only (syslog) |
Yes | Yes | Yes/No | Log fatal errors (syslog, stderr) and key generation messages |
Quiet mode is controlled by the QuietMode keyword in the server configuration file, given an argument of yes or no (the default):
or by the -q command-line option:# SSH1, SSH2 QuietMode yes
# SSH1, SSH2, OpenSSH $ sshd -q
TIP: We strongly recommend compiling SSH2 with heavy debugging turned on, using the flag -- enable-debug-heavy. [Section 4.1.5.14, "Debug output"] The resulting log messages are far more detailed than those printed by default.
The integer levels supported at press time are illustrated in Example 5-1. Specifying a debug level of n means that messages for all levels less than or equal to n will be printed. For instance, a debug level of 9 means that debug messages for levels 0-9 are printed.# SSH2 only $ sshd2 -d 1
Not to be used inside loops: 0) Software malfunctions 1) 2) (0-2 should also be logged using log-event) 3) External non-fatal high level errors - incorrect format received from an outside source - failed negotiation 4) Positive high level info - succeeded negotiation 5) Start of a high or middle level operation - start of a negotiation - opening of a device - not to be used by functions which are called from inside loops Can be used inside loops: 6) Uncommon situations which might be caused by a bug 7) Nice-to-know info - Entering or exiting a function - A result of a low level operation 8) Data block dumps - hash - keys - certificates - other non-massive data blocks 9) Protocol packet dumps - TCP - UDP - ESP - AH 10) Mid-results - inside loops - non-final results 11-15) For programmers own debug use - own discretion - needed only by a person doing bughunt
The complete set of module names for SSH2 2.3.0 is found in Table 5-6.#define SSH_DEBUG_MODULE "Ssh2AuthPasswdServer"
ArcFour |
GetOptCompat |
Main |
Scp2 |
Sftp2 |
SftpCwd |
SftpPager |
Ssh1KeyDecode |
Ssh2 |
Ssh2AuthClient |
Ssh2AuthCommonServer |
Ssh2AuthHostBasedClient |
Ssh2AuthHostBasedRhosts |
Ssh2AuthHostBasedServer |
Ssh2AuthKerberosClient |
Ssh2AuthKerberosServer |
Ssh2AuthKerberosTgtClient |
Ssh2AuthKerberosTgtServer |
Ssh2AuthPasswdClient |
Ssh2AuthPasswdServer |
Ssh2AuthPubKeyClient |
Ssh2AuthPubKeyServer |
Ssh2AuthServer |
Ssh2ChannelAgent |
Ssh2ChannelSession |
Ssh2ChannelSsh1Agent |
Ssh2ChannelTcpFwd |
Ssh2ChannelX11 |
Ssh2Client |
Ssh2Common |
Ssh2PgpPublic |
Ssh2PgpSecret |
Ssh2PgpUtil |
Ssh2Trans |
Ssh2Transport |
SshADT |
SshADTArray |
SshADTAssoc |
SshADTList |
SshADTMap |
SshADTTest |
SshAdd |
SshAgent |
SshAgentClient |
SshAgentPath |
SshAppCommon |
SshAskPass |
SshAuthMethodClient |
SshAuthMethodServer |
SshBufZIP |
SshBuffer |
SshBufferAux |
SshConfig |
SshConnection |
SshDSprintf |
SshDebug |
SshDecay |
SshDirectory |
SshEPrintf |
SshEncode |
SshEventLoop |
SshFCGlob |
SshFCRecurse |
SshFCTransfer |
SshFSM |
SshFastalloc |
SshFileBuffer |
SshFileCopy |
SshFileCopyConn |
SshFileXferClient |
SshFilterStream |
SshGenCiph |
SshGenMP |
SshGetCwd |
SshGlob |
SshInet |
SshKeyGen |
SshPacketImplementation |
SshPacketWrapper |
SshPgpCipher |
SshPgpFile |
SshPgpGen |
SshPgpKey |
SshPgpKeyDB |
SshPgpPacket |
SshPgpStringToKey |
SshProbe |
SshProtoSshCrDown |
SshProtoSshCrup |
SshProtoTrKex |
SshReadLine |
SshReadPass |
SshRegex |
SshSPrintf |
SshServer |
SshServerProbe |
SshSftpServer |
SshSigner2 |
SshStdIOFilter |
SshStream |
SshStreamPair |
SshStreamstub |
SshTUserAuth |
SshTime |
SshTimeMeasure |
SshTimeMeasureTest |
SshTtyFlags |
SshUdp |
SshUdpGeneric |
SshUnixConfig |
SshUnixPtyStream |
SshUnixTcp |
SshUnixUser |
SshUnixUserFiles |
SshUserFileBuffer |
SshUserFiles |
Sshd2 |
TestMod |
TestSshFileCopy |
TestSshGlob |
TestTtyFlags |
t-fsm |
To extract the current set of module names from the source code, search for SSH_DEBUG_MODULE in all source files from the root of the SSH2 distribution:
Once you have identified the name of your desired module, run the server in debug mode, providing the module's name and debug level:$ find . -type f -exec grep SSH_DEBUG_MODULE '{}' \;
This causes the given module to print log messages at the given debug level. For example:$ sshd2 -d "module_name=debug_level_integer"
causes the Ssh2AuthPasswdServer module to log at debug level 2. The messages provide the name of the function in which they occur and the name of the source file in which the code is found. Multiple modules may be specified, separated by commas, each set to individual debug levels:$ sshd2 -d "Ssh2AuthPasswdServer=2"
Additionally, the wildcards * and ? can specify multiple module names:$ sshd2 -d "Ssh2AuthPasswdServer=2,SshAdd=3,SshSftp=1"
Remember to enclose the patterns in single quotes to prevent their expansion by the Unix shell. Note that just because a source code file has a debugging module name associated with it, doesn't mean it actually logs any information that way. You may find that turning on debugging for specific modules doesn't produce any extra debugging output.$ sshd2 -d 'Ssh2*=3'
However, many inetd 's don't allow embedded spaces in program arguments (i.e., they don't recognize the quoting used in this example). You can get around this using a separate script, like so:ssh stream tcp nowait root /bin/sh /bin/sh -c "/usr/sbin/sshd2 -i -d2 2> /tmp/foo"
/etc/inetd.conf ssh stream tcp nowait root /path/to/debug-sshd2-i debug-sshd2-i debug-sshd2-i #!/bin/sh # redirect sshd2 standard error to a file exec /usr/local/sbin/sshd2 -i -d2 2> /tmp/sshd2.debug
or by the VerboseMode keyword in the server configuration file, with a value of yes or no (the default):# SSH2 only $ sshd2 -v Using -v $ sshd2 -d 2 Identical to the preceding line
# SSH2 only VerboseMode yes
# SSH1, SSH2 FascistLogging yes
Or by the -q command-line option of sshd:# SSH1, SSH2 QuietMode yes
# SSH1, SSH2, OpenSSH $ sshd -q
QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUGLogging with level DEBUG violates user privacy and should be used only to diagnose problems, not for normal operation. If sshd is run in debug mode (-d ), logging goes to standard error instead of to syslog. Quiet mode (LogLevel Quiet or sshd -q) sends nothing to the system log (although some messages resulting from OpenSSH activity may still be recorded, such as those from PAM).
5.7. Subsystems | 5.9. Compatibility Between SSH-1 and SSH-2 Servers |
Copyright © 2002 O'Reilly & Associates. All rights reserved.