[英]connect to host localhost port 22: Connection refused
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有人可以帮我解决这个错误,而不是更改端口号
If install Hadoop on Mac OSX, make sure turn on Remote Login under System Preferences then File Sharing .如果在 Mac OSX 上安装 Hadoop,请确保在System Preferences下打开Remote Login然后File Sharing 。 This worked on my machine.这在我的机器上有效。
Remove SSH with the following command:使用以下命令删除 SSH:
sudo apt-get remove openssh-client openssh-server
Install SSH again with:再次安装 SSH:
sudo apt-get install openssh-client openssh-server
It will solve your problem.它会解决你的问题。
Try installing whole SSH package pack:尝试安装整个 SSH 软件包:
sudo apt-get install ssh
I had ssh
command on my Ubuntu but got the error as you have.我在我的 Ubuntu 上有ssh
命令,但和你一样得到了错误。 After full installation all was resolved.完全安装后,一切都解决了。
Check if this port is open.检查此端口是否打开。 Maybe your SSH demon is not running.也许您的 SSH 恶魔没有运行。 See if sshd is running.查看 sshd 是否正在运行。 If not, then start it.如果没有,那就开始吧。
I did all the suggestion above and it did not work.我做了上面的所有建议,但没有奏效。 Then I restart the ssh service and it works.然后我重新启动 ssh 服务,它工作正常。 This is what I do:这就是我所做的:
service ssh restart
Then I redo然后我重做
ssh localhost
Now I can connect to my localhost.现在我可以连接到我的本地主机。 Hope it helps希望能帮助到你
If you restart service then it will work如果您重新启动服务,它将起作用
$ service sshd restart
then check然后检查
$ ssh localhost
It will work它会工作
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.没有任何东西能够与主机通信……在任何端口上。
I used:我用了:
sudo service ssh start
Then:然后:
ssh localhost
对于我的情况(ubuntu 14.04,全新安装),我只需运行以下命令即可!
sudo apt-get install ssh
For what its worth I got the following error trying to ssh into my local machine, running Ubuntu 16.04 Xenial, from a vm.对于它的价值,我尝试从虚拟机通过 ssh 连接到运行 Ubuntu 16.04 Xenial 的本地机器时出现以下错误。
ssh: connect to host 192.168.144.18 port 22: Connection refused
It got immediately fixed with:它立即得到修复:
sudo apt-get install ssh
Take note, Before fix: 'which sshd' returned nothing and 'which ssh' returned请注意,修复之前:'which sshd' 没有返回任何内容,而 'which ssh' 返回
/usr/bin/ssh
And After the fix: 'which sshd' returned修复后:'which sshd' 返回
/usr/sbin/sshd
It might be caused by some of the following:它可能是由以下一些原因引起的:
apt-get install ssh openssh-client openssh-server
未安装 SSH 服务器(仅 SSH 客户端),请尝试: apt-get install ssh openssh-client openssh-server
ufw allow ssh
连接被 iptables(防火墙)阻止,请尝试: ufw allow ssh
On mac go to system settings->network->sharing and allow remote login.在 Mac 上,转到系统设置->网络->共享并允许远程登录。
try ssh localhost尝试 ssh 本地主机
You should be good.你应该很好。
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.我尝试了上述所有解决方案,但不知何故,我仍然缺少这个目录 /var/run/sshd。 I have Ubuntu 16.04.4 LTS.我有 Ubuntu 16.04.4 LTS。 Hope my answer helps if someone has the same issue.如果有人遇到同样的问题,希望我的回答能有所帮助。 ubuntu ssh xenial ubuntu ssh xenial
sudo systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor prese>
Active: inactive (dead)
Docs: man:sshd(8)
man:sshd_config(5)
sudo systemctl enable sshd
sudo systemctl start sshd
My port number is different.我的端口号不同。 i tried using我尝试使用
ssh localhost -p 8088
this worked for me这对我有用
If you still face problems, try the following:如果您仍然遇到问题,请尝试以下操作:
sudo ufw enable
sudo apt-get install openssh-server
This might work too.这也可能有效。
Actually i solved this, I just installed shh daemon.实际上我解决了这个问题,我刚刚安装了 shh 守护进程。
in terminal :在终端:
sudo apt-get install openssh-server须藤 apt-get 安装 openssh-server
A way to do is to go to terminal一种方法是去终端
$ sudo gedit /etc/hosts
***enter your ip address ipaddress of your pc localhost
ipaddress of your pc localhost(Edit your pc name with localhost) **
and again restart your ssh service using:并再次使用以下命令重新启动您的 ssh 服务:
$ service ssh restart
Problem will be resolve.问题将得到解决。 Thanks谢谢
if you are using centOS or Red Hat, you should first update SElinux.如果您使用的是centOS 或Red Hat,您应该首先更新SElinux。 Execute the following statement执行以下语句
ausearch -c 'sshd' --raw | audit2allow -M my-sshd
then you need to execute那么你需要执行
semodule -i my-sshd.pp
good luck祝你好运
If you're certain that you have installed ssh, then it's possible that ssh
and/or sshd
has been terminated or the server service hasn't been started.如果您确定已经安装了 ssh,那么ssh
和/或sshd
可能已终止或服务器服务尚未启动。 To check whether these processes are running use:要检查这些进程是否正在运行,请使用:
//this tells you whether your ssh instance is active/inactive
sudo service ssh status
OR或者
//this list all running processes whose names contain the string "ssh"
sudo ps -A | grep ssh
It's likely that ssh
would be active and running but sshd
would not. ssh
很可能会处于活动状态并正在运行,但sshd
不会。 To enable them:要启用它们:
sudo service ssh start
NB;注意; - some systems have a restart option but mine didn't - 一些系统有重启选项,但我的没有
try sudo vi /etc/ssh/sshd_config
试试sudo vi /etc/ssh/sshd_config
in first few lies you'll find在最初的几个谎言中你会发现
Package generated configuration file打包生成的配置文件
See the sshd_config(5) manpage for details有关详细信息,请参阅 sshd_config(5) 联机帮助页
What ports, IPs and protocols we listen for我们侦听哪些端口、IP 和协议
Port xxxxx端口xxxxx
change Port xxxxx to "Port 22" and exit vi by saving changes.将端口 xxxxx 更改为“端口 22”并通过保存更改退出 vi。
restart ssh sudo service ssh restart
重新启动 ssh sudo service ssh restart
You may should edit your /etc/hosts
.您可能应该编辑您的/etc/hosts
。 For example if my hostname
is ub0
, but the hostname
in /etc/hosts
is localhost
, it may occur例如,如果我的hostname
是ub0
,但hostname
在/etc/hosts
的localhost
,就可能发生
connect to host ub0 port 22: Connection refused
Because the hostname
in /etc/hosts
is localhost
not ub0
.由于hostname
在/etc/hosts
的localhost
不ub0
。
So, you should be careful the hostname
when building up distributed clusters.因此,在构建分布式集群时应该注意hostname
。
For Linux:对于 Linux:
Remove SSH with the following command:使用以下命令删除 SSH:
sudo apt-get remove openssh-client openssh-server
Install SSH again with:再次安装 SSH:
sudo apt-get install openssh-client openssh-server
您需要检查 sshd_config ListenAddress 0.0.0.0 中的配置更新此并重新启动将解决问题的 sshd 服务。
if you are able to ping and not able to ssh, then it is a firewall.如果您可以 ping 而不能 ssh,则它是防火墙。 The firewall on 18.4 (not sure about other versions) in on by default and only allow port 8080. 18.4 上的防火墙(不确定其他版本)默认开启,只允许端口 8080。
Here how you fix it在这里你如何修复它
https://linuxconfig.org/how-to-enable-disable-firewall-on-ubuntu-18-04-bionic-beaver-linux https://linuxconfig.org/how-to-enable-disable-firewall-on-ubuntu-18-04-bionic-beaver-linux
Check file /etc/ssh/sshd_config for Port number.检查文件 /etc/ssh/sshd_config 的端口号。 Make sure it is 22.确保它是 22。
What worked for me was modifying the ssh config file to the following:对我有用的是将 ssh 配置文件修改为以下内容:
Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa Host * AddKeysToAgent 是 UseKeychain 是 IdentityFile ~/.ssh/id_rsa
if youre apache server is not running your local host wont run check that out there are some articles if you dont get it i will leave a link here ;)如果你的 apache 服务器没有运行你的本地主机不会运行检查有没有一些文章如果你没有得到它我会在这里留下一个链接;)
I had same error got it done rn我有同样的错误完成它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.