ssh_client和server功能调试

本文介绍了SSH连接中常见的四种错误及其解决方案,包括验证方式不支持、普通用户登录密码始终错误、PRNG未播种以及PTY分配请求失败等问题,并提供了详细的步骤来帮助读者解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 验证方式不支持

  如客户端登录时提示如下:

[www.linuxidc.com@CentOS-6-37 ~]$ ssh monitor@192.168.1.5

Permission denied (publickey,keyboard-interactive).

  解决方法:

    设置sshd的配置文件(sshd_config)的这条配置:PasswordAuthentication yes

    然后重启服务:service sshd restart


2 普通用户登录密码始终错误,sshd启动有报错

  sshd启动报错:

    Unsupported option GSSAPIAuthentication
    Unsupported option GSSAPICleanupCredentials

  解决方法:

    注销sshd的配置文件(sshd_config)的如下配置:

    #GSSAPIAuthentication yes
    #GSSAPICleanupCredentials yes
    #UsePAM yes

    然后重启服务:service sshd restart

3. 报错 PRNG is not seeded

root@localhost:/# /etc/init.d/ssh restart
PRNG is not seeded

After investigation we found that the /dev/urandom was not there on the VPS.

root@localhost:/dev# ls -al /dev/random
crw-r--r-- 1 root root 1, 8 Mar  2 19:28 /dev/random

root@localhost:/dev# ls -al /dev/urandom
ls: cannot access /dev/urandom: No such file or directory

By the below command, we created it and restarted SSH

root@localhost:/dev# mknod /dev/urandom c 1 9
root@localhost:/dev# /etc/init.d/ssh  restart
* Restarting OpenBSD Secure Shell server sshd
...done.

4. 报错:

PTY allocation request failed on channel 0

可以用如下方式修改

1.rm -rf /dev/ptmx
2.mknod /dev/ptmx c 5 2
3.chmod 666 /dev/ptmx
4.umount /dev/pts
5.rm -rf /dev/pts
6.mkdir /dev/pts
7.mount /dev/pts


PS C:\Users\赵嘉楠> ssh -v 10.10.11.160 OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 debug1: Reading configuration data C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 1: Applying options for * debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 5: Applying options for 10.10.11.160 debug1: Connecting to 10.10.11.160 [10.10.11.160] port 22. debug1: Connection established. debug1: identity file C:\\Users\\\350\265\265\345\230\211\346\245\240\\.ssh\\id_ed25519 type 3 debug1: identity file C:\\Users\\\350\265\265\345\230\211\346\245\240\\.ssh\\id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_for_Windows_9.5 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 debug1: compat_banner: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to 10.10.11.160:22 as 'jianan.zhao' debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-ed25519 SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0 debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: hostkeys_find_by_key_hostfile: hostkeys file C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2 does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts2 does not exist The authenticity of host '10.10.11.160 (10.10.11.160)' can't be established. ED25519 key fingerprint is SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])?
最新发布
03-20
<think>嗯,用户运行了ssh -v 10.10.11.160,然后得到了一堆调试信息。首先,我需要分析这些输出,看看用户遇到了什么问题。看起来用户可能不太清楚这些调试信息的意思,或者是在连接过程中遇到了什么障碍,比如主机认证的问题。 首先,注意到用户使用的是Windows系统,因为提示符是PowerShell的PS路径。OpenSSH的版本是Windows的9.5p1,而远程服务器是Ubuntu的OpenSSH 7.6p1。版本之间的兼容性可能没问题,但需要确认。 接下来,调试信息显示用户尝试以用户名'jianan.zhao'连接到10.10.11.160的22端口。连接建立后,开始进行密钥交换。这里的关键点是服务器的主机密钥指纹没有被本地识别,因为known_hosts文件不存在。所以系统提示用户是否继续连接,这时候用户可能需要输入yes/no或者验证指纹。 用户可能遇到的问题是不确定是否应该信任这个主机,或者不知道如何处理这个提示。此外,用户可能想了解整个SSH连接过程的各个步骤,比如密钥交换、认证过程等。 需要解释的是,SSH首次连接时会提示确认主机指纹,这是为了防止中间人攻击。用户需要确认服务器指纹的正确性,通常是通过其他途径获取正确的指纹并比对。如果用户信任该服务器,输入yes后,指纹会被保存到known_hosts文件中,下次连接就不会再提示了。 另外,用户可能对调试信息中的各个部分不太理解,比如kex算法、密钥类型、身份文件等。需要逐一解释这些术语,帮助用户理解连接过程中发生了什么。 可能还需要提醒用户,如果遇到连接问题,可能是网络问题、服务器未运行SSH、防火墙设置等,但根据当前的输出,连接已经建立,只是卡在主机认证这一步。所以重点应放在主机密钥验证的过程解决方法上。 总结来说,用户需要了解SSH连接的基本流程,特别是首次连接时的主机验证,以及如何正确处理未知主机的提示。同时,解释调试信息中的关键点,帮助用户诊断问题,确保连接的安全性。</think>以下是您执行 `ssh -v 10.10.11.160` 时输出的逐段解析问题排查指南: --- ### **1. 客户端基本信息** ```plaintext OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 ``` - **含义**:客户端使用的是 Windows 版 OpenSSH 9.5,加密库为 LibreSSL 3.8.2。 --- ### **2. 配置文件加载** ```plaintext debug1: Reading configuration data C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 1: Applying options for * debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 5: Applying options for 10.10.11.160 ``` - **含义**:客户端正在读取用户目录下的 SSH 配置文件 `~/.ssh/config`,并对所有主机(`*`)特定主机 `10.10.11.160` 应用配置规则。 - **注意**:路径中的乱码 `\350\265\265...` 可能是中文用户名编码问题(如“赵嘉楠”),但 SSH 客户端已正确处理。 --- ### **3. 连接建立** ```plaintext debug1: Connecting to 10.10.11.160 [10.10.11.160] port 22. debug1: Connection established. ``` - **含义**:客户端成功通过 TCP 22 端口连接到目标服务器 `10.10.11.160`。 --- ### **4. 密钥与认证** ```plaintext debug1: identity file C:\\Users\\...\\.ssh\\id_ed25519 type 3 debug1: identity file C:\\Users\\...\\.ssh\\id_ed25519-cert type -1 ``` - **含义**:客户端尝试使用 Ed25519 密钥 `id_ed25519` 进行身份验证,但未找到对应的证书文件(`-1` 表示未使用证书)。 --- ### **5. 协议版本协商** ```plaintext debug1: Local version string SSH-2.0-OpenSSH_for_Windows_9.5 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 ``` - **含义**:客户端与服务器均支持 SSH 2.0 协议,服务器运行的是 Ubuntu 系统的 OpenSSH 7.6p1。 --- ### **6. 密钥交换(KEX)** ```plaintext debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com debug1: kex: client->server cipher: chacha20-poly1305@openssh.com ``` - **含义**:双方协商使用以下加密参数: - **密钥交换算法**:`curve25519-sha256` - **主机密钥类型**:`Ed25519` - **数据传输加密算法**:`chacha20-poly1305` --- ### **7. 主机密钥验证** ```plaintext debug1: Server host key: ssh-ed25519 SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0 The authenticity of host '10.10.11.160 (10.10.11.160)' can't be established. ED25519 key fingerprint is SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0. ``` - **关键问题**:客户端首次连接此服务器,无法在本地 `known_hosts` 文件中找到该服务器的密钥记录。 - **解决方案**: 1. 若服务器是受信任的,输入 `yes` 接受密钥并保存到 `~/.ssh/known_hosts`。 2. 若需验证指纹,需通过其他可信渠道(如服务器管理员)获取正确的指纹进行比对。 --- ### **8. 连接中断的可能原因** - **网络问题**:检查 `10.10.11.160` 是否可达(如 `ping 10.10.11.160`)。 - **服务未运行**:确认服务器 SSH 服务已启动(默认端口 22)。 - **防火墙限制**:确保本地或服务器防火墙未阻止 22 端口。 --- ### **总结** 当前连接已成功建立,但需验证服务器指纹的真实性。输入 `yes` 接受密钥后,后续连接将不再提示。若需更高安全性,建议通过其他方式确认指纹后再继续。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值