ssh_client和server功能调试

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

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


ipssh_send_kex_dh_init(Ipssh_conn* ssh_conn) { Ip_err rc = IPCOM_ERR_FAILED; Ipcom_buffer* pkt; Ip_u8* ptr; int len; IPCOM_LOG1(DEBUG, "ipssh_send_kex_dh_init :: ssh_conn: %x", ssh_conn); pkt = ipssh_buffer_new_v2_pkt(1024, IPSSH_MSG_KEXDH_INIT); if(!pkt) { IPCOM_LOG0(ERR, "ipssh_send_kex_dh_init :: out of memory"); return IPCOM_ERR_FAILED; } if (ssh_conn->conn_prop_pending.kex_alg[0] == IPSSH_KEYEX_DH_GR14_SHA1_ID || ssh_conn->conn_prop_pending.kex_alg[0] == IPSSH_KEYEX_DH_GR14_SHA256_ID) { if(!(ssh_conn->dh_data->dh = ipssh_create_dh_group14())) { IPCOM_LOG0(ERR, "ipssh_send_msg_kex_dh_init :: ipssh_create_dh_group14() failed"); goto cleanup; } } else { if(!(ssh_conn->dh_data->dh = ipssh_create_dh_group1())) { IPCOM_LOG0(ERR, "ipssh_send_msg_kex_dh_init :: ipssh_create_dh_group1() failed"); goto cleanup; } } /* Generate random number y and create e = g^x mod p */ if(!DH_generate_key(ssh_conn->dh_data->dh)) { IPCOM_LOG0(ERR, "ipssh_send_msg_kex_dh_init :: DH_generate_key() failed"); goto cleanup; } ptr = ipcom_buffer_end_ptr(pkt); if(ipssh_buffer_put_bn(pkt, ssh_conn->dh_data->dh->pub_key) < 0) { IPCOM_LOG0(ERR, "ipssh_send_msg_kex_dh_init :: ipssh_buffer_put_bn() failed"); goto cleanup; } ptr += 4; /* proceed past length field */ len = ipcom_buffer_end_ptr(pkt) - ptr; if(ipssh_msg2list((Ipssh_msg_list*)&(ssh_conn->handshake_msgs), IPSSH_MPINT, ptr, len, 5)) { IPCOM_LOG0(ERR, "ipssh_send_kex_dh_reply :: ipssh_msg2list() failed for f"); goto cleanup; } if(ipssh_send_pkt(ssh_conn, pkt, IP_FALSE) == IPCOM_SUCCESS) { rc = IPCOM_SUCCESS; } cleanup: if(pkt) ipcom_buffer_free(pkt); return rc; }用流程图表示以上代码的功能,并关注这段代码在ssh的密钥交换过程中,不同种类密钥生成的时机(哪个函数生成的)
最新发布
11-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值