ssh: connect to host localhost port 22: Connection refused引发的一系列问题解决

ssh: connect to host localhost port 22: Connection refused引发的一系列问题解决


在配置伪分布式hadoop的时候,新手总是容易出现ssh验证的问题。
所以借此机会把自己用WSL2 Ubuntu时遇到的一些ssh问题,以后也方便查阅。

1. connect to host localhost port 22

localhost: ssh: connect to host localhost port 22: Connection refused

遇到这个问题,首先查看是否安装了ssh,并查看ssh进程是否开启。

  • 安装ssh服务
apt-get install ssh openssh-server
  • 可以选择两种方式打开ssh服务
/etc/init.d/ssh start
sudo service ssh start

查看进程

ps -e | grep sshd

下图为进程开启时。
在这里插入图片描述

2. no hostkeys available

提示

sshd: no hostkeys available — exiting

可以查看一下/etc/ssh/目录下是否有对应的key文件,如若没有,则可以尝试下面两条指令生成。

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

3.connect to host 0.0.0.0 port 22

0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
The authenticity of host '0.0.0.0 (0.0.0.0)' can't be established.
RSA key fingerprint is SHA256:KxxxxxxxxxxxxxxxxxxOcFgE.

遇到这两个错,查阅资料说是本地地址没有配置免密码登录,直接在shell中yes就可以了

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

不成功可以试试下面这个

ssh-copy-id -i ~/.ssh/id_rsa.pub 0.0.0.0  

另:在修改过xml文件之后,如果有节点启动不成功,可以想想是不是改动了部分的目录,再对症下药。

  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值