Linux 连接到主机 localhost 端口 22:连接被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17335728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:19:22  来源:igfitidea点击:

connect to host localhost port 22: Connection refused

linuxhadoopssh

提问by Surya

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

在我的本地机器上安装 hadoop 时,出现以下错误

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

有人可以帮我解决这个错误,而不是更改端口号

采纳答案by Surya

My port number is different. i tried using

我的端口号不同。我尝试使用

ssh localhost -p 8088

this worked for me

这对我有用

回答by abhinav

Check if this port is open. Maybe your SSH demon is not running. See if sshd is running. If not, then start it.

检查此端口是否打开。也许您的 SSH 恶魔没有运行。查看 sshd 是否正在运行。如果没有,那就开始吧。

回答by Tariq

Do you have sshdinstalled? You can verify that with:

sshd安装了吗?您可以通过以下方式验证:

which ssh
which sshd

For detailed information you can visit this link.

有关详细信息,您可以访问此链接

回答by Larry Helms

Make sure that /etc/hosts.allow contains:

确保 /etc/hosts.allow 包含:

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

确保文件中的第一行不以 ALL:ALL:DENY 开头

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

没有任何东西能够与主机通信……在任何端口上。

回答by vladof81

If install Hadoop on Mac OSX, make sure turn on Remote Loginunder System Preferencesthen File Sharing. This worked on my machine.

如果在 Mac OSX 上安装 Hadoop,请确保在System Preferences下打开Remote Login然后File Sharing。这在我的机器上有效。

Remote Login

远程登录

回答by Divyang Shah

  1. Remove SSH with the following command:

    sudo apt-get remove openssh-client openssh-server
    
  2. Install SSH again with:

    sudo apt-get install openssh-client openssh-server
    
  1. 使用以下命令删除 SSH:

    sudo apt-get remove openssh-client openssh-server
    
  2. 再次安装 SSH:

    sudo apt-get install openssh-client openssh-server
    

It will solve your problem.

它会解决你的问题。

回答by Michael Z

Try installing whole SSH package pack:

尝试安装整个 SSH 软件包:

sudo apt-get install ssh

I had sshcommand on my Ubuntu but got the error as you have. After full installation all was resolved.

ssh在我的 Ubuntu 上有命令,但和你一样得到了错误。完全安装后一切都解决了。

回答by Dinesh

If you still face problems, try the following:

如果您仍然遇到问题,请尝试以下操作:

sudo ufw enable    
sudo apt-get install openssh-server

This might work too.

这也可能有效。

回答by GoingMyWay

You may should edit your /etc/hosts. For example if my hostnameis ub0, but the hostnamein /etc/hostsis localhost, it may occur

您可能应该编辑您的/etc/hosts. 例如,如果 myhostnameub0,但hostnamein/etc/hostslocalhost,则可能会发生

connect to host ub0 port 22: Connection refused

Because the hostnamein /etc/hostsis localhostnot ub0.

因为hostname/etc/hostslocalhost没有ub0

So, you should be careful the hostnamewhen building up distributed clusters.

因此,hostname在构建分布式集群时应该小心。

回答by Shiqing Fan

For my case(ubuntu 14.04, fresh installed), I just run the following command and it works!

对于我的情况(ubuntu 14.04,全新安装),我只需运行以下命令即可!

sudo apt-get install ssh

sudo apt-get install ssh