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文件之后,如果有节点启动不成功,可以想想是不是改动了部分的目录,再对症下药。