5.8.2.2. SSH2 Debug mode (module-based)
Debug levels can also be set differently for each source code
"module" of SSH2. This permits finer-grained control over
logging, as well as producing tons of output. This type of debugging
is documented only within the source code
(lib/sshutil/sshcore/sshdebug.h), so to use this
mode effectively, you should have some C programming knowledge.
A SSH2 source file is defined to be a "module" for
debugging purposes, by defining SSH_DEBUG_MODULE within the file. For
example, the file apps/ssh/auths-passwd.c has
the module name Ssh2AuthPasswdServer because it contains the line:
#define SSH_DEBUG_MODULE "Ssh2AuthPasswdServer"
The complete set of module names for SSH2 2.3.0 is found in Table 5-6.
Table 5-6. SSH2 Module Names
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:
$ find . -type f -exec grep SSH_DEBUG_MODULE '{}' \;
Once you have identified the name of your desired module, run the
server in debug mode, providing the module's name and debug
level:
$ sshd2 -d "module_name=debug_level_integer"
This causes the given module to print log messages at the given debug
level. For example:
$ sshd2 -d "Ssh2AuthPasswdServer=2"
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,SshAdd=3,SshSftp=1"
Additionally, the wildcards * and ? can specify multiple module
names:
$ sshd2 -d 'Ssh2*=3'
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.