connect to host localhost port 22: Connection refu

2019-03-07 17:25发布

While installing hadoop in my local machine , i got following error

ssh -vvv localhost 
OpenSSH_5.5p1, OpenSSL 1.0.0e-fips 6 Sep 2011 
debug1: Reading configuration data /etc/ssh/ssh_config    
debug1: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to localhost [127.0.0.1] port 22. 
debug1: connect to address 127.0.0.1 port 22: Connection refused 
ssh: connect to host localhost port 22: Connection refused

can some one help me to resolve this error , than changing port number

标签: linux hadoop ssh
24条回答
混吃等死
2楼-- · 2019-03-07 17:57

I used:

sudo service ssh start

Then:

ssh localhost
查看更多
Luminary・发光体
3楼-- · 2019-03-07 17:58

Make sure that /etc/hosts.allow contains:

ssh:ALL:allow
sshd:ALL:allow

OR

ssh:localhost:allow
sshd:localhost:allow

OR - some other variant

ssh:{host1,host2,host3...}:allow
sshd{host1,host2,host3...}:allow

INSURE that the first line in the file DOES NOT begin with ALL:ALL:DENY

NOTHING will be able to communicate with the host... on any port.

查看更多
4楼-- · 2019-03-07 17:59

If you still face problems, try the following:

sudo ufw enable    
sudo apt-get install openssh-server

This might work too.

查看更多
乱世女痞
5楼-- · 2019-03-07 18:00

Do you have sshd installed? You can verify that with:

which ssh
which sshd

For detailed information you can visit this link.

查看更多
Rolldiameter
6楼-- · 2019-03-07 18:02

What worked for me is:

sudo mkdir /var/run/sshd
sudo apt-get install --reinstall openssh-server

I tried all the above mentioned solutions but somehow this directory /var/run/sshd was still missing for me. I have Ubuntu 16.04.4 LTS. Hope my answer helps if someone has the same issue.

查看更多
你好瞎i
7楼-- · 2019-03-07 18:02

if you are able to ping and not able to ssh, then it is a firewall. The firewall on 18.4 (not sure about other versions) in on by default and only allow port 8080.

Here how you fix it

https://linuxconfig.org/how-to-enable-disable-firewall-on-ubuntu-18-04-bionic-beaver-linux

查看更多
登录 后发表回答