ssh服务连接服务器异常

25 篇文章 0 订阅
23 篇文章 0 订阅

1. 问题1

1、背景

ansible批量安装Prometheus监控时存在个别主机ping命令时异常
在这里插入图片描述

10.xxx.xxx.xxx | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ED25519 key sent by the remote host is\nSHA256:u79JrY6CPeDHMC7THWhLeek/BvnZ4AmFFj37YrndGiw.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:70\r\nPassword authentication is disabled to avoid man-in-the-middle attacks.\r\nKeyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.\r\nUpdateHostkeys is disabled because the host key is not trusted.\r\n\nAuthorized users only. All activities may be monitored and reported.\nroot@10.223.225.161: Permission denied (publickey,gssapi-with-mic,password).",
    "unreachable": true
}

使用ssh连接时
在这里插入图片描述

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ED25519 key sent by the remote host is
SHA256:5EA+FhrKm+TIVacBJhpOISexNpdmgY51FXFK6Ph4E98.
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:64
Host key for xx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

2、处理

使用ssh-keygen -R xx.xxx.xxx.xxx 重新拷贝公钥信息

ssh-keygen -R xx.xxx.xxx.xxx
Host xx.xxx.xxx.xxx not found in /root/.ssh/known_hosts
  • 发现相关认证文件不存在,登陆到服务器上查看实际是存在的

3、处理办法

  1. 重命名配置文件:mv /root/.ssh/known_hosts /root/.ssh/known_hosts-bak
  2. 重新执行命令:ssh-keygen -R xxx.xxx.xxx.xxx
    在这里插入图片描述

2. 问题2

个别服务存在密码错误或无效

在这里插入图片描述

密码无效/不正确:\n仅限授权用户。所有活动均可进行监测和报告。\n许可被拒绝,请重试。
  • 使用ssh测试发现密码实际正确

解决办法

ansible_ssh_pass密码字段将密码使用双引号包裹起来ansible_ssh_pass="密码"
存在该现象的密码存在同一个现象,密码中有’#’ 符,可能时由于改特殊字符导致

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SSH连接服务器失败时,出现的错误提示"ssh: connect to host [IP地址] port 22: Connection refused"。这个错误通常表示无法建立与目标服务器SSH连接。有几个可能的原因和解决办法可以尝试解决此问题。 首先,确保目标服务器SSH服务已经启动。可以通过运行命令"sudo service ssh status"来检查SSH服务的状态。如果SSH服务未运行,可以使用命令"sudo service ssh start"启动服务。 其次,确认目标服务器SSH端口是否正确。默认情况下,SSH使用端口22。如果SSH端口被更改,确保你正在使用正确的端口进行连接。可以通过命令"sudo vi /etc/ssh/sshd_config"来编辑SSH配置文件并检查"Port"选项。 另外,防火墙可能会阻止SSH连接。检查目标服务器的防火墙配置,并确保允许通过SSH连接的流量。可以使用命令"sudo ufw status"或"sudo iptables -L"来检查防火墙规则,并根据需要进行相应的配置更改。 最后,确保本地计算机上已安装SSH客户端。如果未安装,可以使用命令"sudo apt-get install openssh-client"在本地计算机上安装SSH客户端。 综上所述,当SSH连接服务器失败时,可以通过以下步骤进行排查和解决: 1. 检查目标服务器SSH服务状态,并启动服务(如果未启动)。 2. 确认使用正确的SSH端口进行连接。 3. 检查目标服务器的防火墙配置,并确保允许SSH连接的流量通过。 4. 在本地计算机上安装SSH客户端(如果未安装)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值