SSH连服务器时,连接不上,出现以下错误的原因与解决办法

您所在的位置:网站首页 松下位移传感器接线方式 SSH连服务器时,连接不上,出现以下错误的原因与解决办法

SSH连服务器时,连接不上,出现以下错误的原因与解决办法

2023-12-21 10:12| 来源: 网络整理| 查看: 265

一.“ssh: connect to host 192.168.110.249 port 22: Connection refused”错误的原因与解决办法

在用ssh远程登陆服务器时遇到如下问题:

ssh: connect to host 192.168.xxx.xxx port 22: Connection refused

解决方法:

1.检查是否安装了openssh-server

ps -e | grep ssh

如果只出现了一个ssh,说明没有安装sshd,使用命令安装sshd服务

apt-get install openssh-server

2.sshd未启动

service sshd restart

ok,现在可以使用ssh连接了 

二.“Permission denied,please try again”错误的原因与解决办法

        有时候我们需要使用ssh连接服务器,一般情况下可以正常连上,不过有时候还是会出现这个错误“Permission denied,please try again”,错误原因: 服务器能拒绝,说明网络和ssh服务没有问题,出现这个问题的最可能的原因是:1.账号不存在; 2.输入密码有误;3.该账号被禁止登录了(如sshd配置文件中禁止root登录)。

解决方法:

1.服务器上用命令(id testroot)查看该用户名是否存在,如不存在,则创建该用户(useradd testroot),并为该用户设置密码(passwd testroot)

# id testroot # useradd testroot # passwd testroot

2.检查并确定密码没有错误

3.若是root用户登录提示上述错误,一般是配置文件中将root设置为不允许远程登录,编辑sshd配置文件,将PermitRootLogin 设置为yes,以允许root登录。最后重启sshd服务(systemctl restart sshd)

vim /etc/ssh/sshd_config  ... PermitRootLogin yes ... systemctl restart sshd

ok,问题解决

3.‘...Host key verification failed’

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:W7VYm+7GNwzifa0h1l9hFWEzSBelJazMTXSYkBn5xyw. Please contact your system administrator. Add correct host key in /root/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /root/.ssh/known_hosts:2 remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R "192.168.110.249" ECDSA host key for 192.168.110.249 has changed and you have requested strict checking. Host key verification failed.

解决方法:

        仔细分析了一下大概是因为192.168.110.249的主机密钥改了,而本机使用的还是原来的公钥与其匹配,因此会出现错误。一旦使用本机ssh连接过目标机,则会在~/.ssh/know_hosts文件下生成目标机的公钥,以便下次可以直接使用。所以,我们可以把该文件下192.168.110.249对应的公钥删除掉,或者直接删除know_hosts

rm -rf ~/.ssh/known_hosts



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3