查看更多教程 https://on  itroad.com

要遵循的步骤

将 sshd 守护进程配置为在调试模式下运行单线程。
我们可以选择:

  1. 停止系统上活动的 sshd,以便可以启动在调试模式下运行的 sshd。

-或者

  1. 在端口 22 以外的空闲端口上启动一个以调试模式运行的新 sshd 实例。
    以下示例用于在调试模式下在不同端口(本例中为 2222)上启动新 sshd:
ssh_server# /usr/lib/ssh/sshd -p 2222 -ddd
debug1: sshd version Sun_SSH_1.1
debug3: Not a RSA1 key file /etc/ssh/ssh_host_rsa_key.
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug3: Not a RSA1 key file /etc/ssh/ssh_host_dsa_key.
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: Bind to port 2222 on ::.
Server listening on :: port 2222

这里输出将停止,直到端口 2222 上的客户端连接被启动。
现在服务器已准备好接受连接;从 ssh 客户端启动调试会话:

root@sshclient# /usr/bin/ssh -p 2222 -vvv 192.168.100.33
Sun_SSH_1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090704f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Rhosts Authentication disabled, oroirnating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to 192.168.100.33 [192.168.100.33] port 2222.
debug1: Connection established.
debug1: identity file /.ssh/identity type -1
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1
debug1: no match: Sun_SSH_1.1
debug1: Enabling compatibility mode for protocol 2.0
debug2: . . (snipped for brevity)

注意:调试输出将滚动。
完成(或者尝试完成)登录会话,以便调试将显示在双方。

对于 sftp 测试,使用 -o 选项和 sftp 来指定端口。

# sftp -oPort=2222 192.168.100.33

对于更详细的调试,可以使用 truss 来捕获系统调用和信号。

在服务器上

# truss -aefdl -rall -wall -vall -xall -o /var/tmp/sshd.truss /usr/lib/ssh/sshd -p 2222 -ddd

在客户端

# truss -aefdl -rall -wall -vall -xall -o /var/tmp/ssh.truss /usr/bin/ssh -p 2222 -vvv 192.168.100.33

建立连接后,服务器调试窗口将继续输出调试数据:

debug1: Server will not fork when running in debugging mode.
Connection from 192.168.100.33 port 56939
debug1: Client protocol version 2.0; client software version Sun_SSH_1.1
debug1: no match: Sun_SSH_1.1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-Sun_SSH_1.1
debug1: list_hostkey_types: ssh-rsa,ssh-dss
debug2: (snipped for brevity)

剪切/粘贴,保存并提供双方的调试输出。

如何为 Solaris 启用 ssh/sshd 调试

这篇文章将展示如何将 ssh(客户端命令)和 sshd(服务器守护进程)置于调试模式,以便对授权和连接问题进行故障排除。
在打开服务请求时,Oracle/Sun 技术支持代理将针对 ssh/sshd 授权和连接问题请求此调试输出。

日期:2020-09-17 00:15:08 来源:oir作者:oir