ssh密码方式登陆Server

本文介绍了一种解决SSH连接失败的问题方案。具体步骤包括:确保服务器端配置正确,如开启密码认证并重启服务;检查客户端连接命令及参数是否正确;使用详细模式定位连接失败的具体原因。

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

服务器环境:操作系统:ubuntu 14.04 64bit

客户端环境:deepin 64bit

服务器端设置:

1.执行以下命令,将“/etc/ssh/sshd_config”中的“PasswordAuthentication”值修改为“yes”。

sudo vi /etc/ssh/sshd_config

2.执行以下命令,重新加载sshd服务。

sudo service sshd reload

3.为安全起见,建议重置Linux弹性云服务器普通帐户的密码 执行以下命令,重置用户名为“linux”的弹性云服务器密码。

sudo passwd linux

4.按照回显提示,输入新密码,按“Enter”

5.重新输入设置的新密码,按“Enter”。

6.系统回显如下时,表明重置成功。

passwd: all authentication tokens updated successfully.

客户端:

客户端通过ssh方式连接服务器出错,官网提供的登陆格式如下:

lsj@lsj-pc:~$ ssh 122.112.224.189
ssh_exchange_identification: read: Connection reset by peer
连接后报错

ping 服务器发现网络连接正常

PING 122.112.224.166 (122.112.224.189) 56(84) bytes of data.
64 bytes from 122.112.224.189: icmp_seq=1 ttl=32 time=45.9 ms
64 bytes from 122.112.224.189: icmp_seq=2 ttl=32 time=73.0 ms
64 bytes from 122.112.224.189: icmp_seq=3 ttl=32 time=43.7 ms
用ssh -v去连有问题的服务器,会有比较详细的调试信息在屏幕上输出,可以帮助判断是哪一步出了问题。
lsj@lsj-pc:~$ ssh -v 122.112.224.189
OpenSSH_7.3p1 Debian-3+b1, OpenSSL 1.0.2j  26 Sep 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 122.112.224.189 [122.112.224.189] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lsj/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3p1 Debian-3+b1
提示路径不正确??


解决方案:

用root身份登陆服务器:

lsj@lsj-pc:~$ ssh root@122.112.224.189
输入root密码


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值