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

s1ag04yj  于 2021-06-04  发布在  Hadoop
关注(0)|答案(28)|浏览(847)

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

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

有人能帮我解决这个错误,比改变端口号

tjvv9vkg

tjvv9vkg1#

它可能是由以下某些原因引起的:
未安装ssh服务器(仅ssh客户端),请尝试: apt-get install ssh openssh-client openssh-server 连接被iptables(防火墙)阻止,请尝试: ufw allow ssh

fafcakar

fafcakar2#

您可以编辑您的 /etc/hosts . 例如,如果我的 hostnameub0 ,但是 hostname/etc/hostslocalhost ,它可能会发生

  1. connect to host ub0 port 22: Connection refused

因为 hostname/etc/hostslocalhost 不是 ub0 .
所以,你应该小心 hostname 在构建分布式集群时。

v9tzhpje

v9tzhpje3#

尝试 sudo vi /etc/ssh/sshd_config 在最初的几个谎言中你会发现
包生成的配置文件
有关详细信息,请参阅sshd_config(5)手册页
我们监听哪些端口、IP和协议
港口xx
将端口xx更改为“端口22”,并通过保存更改退出vi。
重新启动ssh sudo service ssh restart

hs1rzwqc

hs1rzwqc4#

使用以下命令删除ssh:

  1. sudo apt-get remove openssh-client openssh-server

再次安装ssh时使用:

  1. sudo apt-get install openssh-client openssh-server

它会解决你的问题。

wyyhbhjk

wyyhbhjk5#

在安装/重新安装任何东西之前,请检查sshd的状态。

  1. sudo systemctl status sshd

你应该看到像。

  1. sshd.service - OpenSSH server daemon
  2. Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor prese>
  3. Active: inactive (dead)
  4. Docs: man:sshd(8)
  5. man:sshd_config(5)

只需启用并启动sshd

  1. sudo systemctl enable sshd
  2. sudo systemctl start sshd
x8diyxa7

x8diyxa76#

如果您确定已经安装了ssh,那么有可能 ssh 和/或 sshd 已终止或服务器服务尚未启动。要检查这些进程是否正在运行,请使用:

  1. //this tells you whether your ssh instance is active/inactive
  2. sudo service ssh status

  1. //this list all running processes whose names contain the string "ssh"
  2. sudo ps -A | grep ssh

很可能 ssh 将是积极的和运行,但 sshd 不会的。要启用它们:

  1. sudo service ssh start

注意;-有些系统有重启选项,但我的没有

lh80um4z

lh80um4z7#

在mac上,进入系统设置->网络->共享并允许远程登录。
尝试ssh localhost
你应该很好。

zwghvu4y

zwghvu4y8#

一种方法是去终点站

  1. $ sudo gedit /etc/hosts
  2. ***enter your ip address ipaddress of your pc localhost
  3. ipaddress of your pc localhost(Edit your pc name with localhost)**

然后再次使用以下命令重新启动ssh服务:

  1. $ service ssh restart

问题会解决的。谢谢

kt06eoxx

kt06eoxx9#

确保/etc/hosts.allow包含:

  1. ssh:ALL:allow
  2. sshd:ALL:allow

  1. ssh:localhost:allow
  2. sshd:localhost:allow

或者-其他变体

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

确保文件中的第一行不以开头all:all:拒绝
任何东西都无法与主机通信。。。在任何港口。

展开查看全部
lokaqttq

lokaqttq10#

如果仍然面临问题,请尝试以下操作:

  1. sudo ufw enable
  2. sudo apt-get install openssh-server

这也许也行。

watbbzwu

watbbzwu11#

你有 sshd 安装?您可以通过以下方式进行验证:

  1. which ssh
  2. which sshd

有关详细信息,请访问此链接。

taor4pac

taor4pac12#

对于linux:
使用以下命令删除ssh:

  1. sudo apt-get remove openssh-client openssh-server

再次安装ssh时使用:

  1. sudo apt-get install openssh-client openssh-server
gr8qqesn

gr8qqesn13#

对于我的例子(ubuntu14.04,新安装的),我只需运行以下命令就可以了! sudo apt-get install ssh

n3ipq98p

n3ipq98p14#

值得一提的是,我在尝试从虚拟机ssh到本地机器(运行ubuntu16.04xenial)时遇到了以下错误。

  1. ssh: connect to host 192.168.144.18 port 22: Connection refused

它立即得到修复:

  1. sudo apt-get install ssh

请注意,在修复之前:“which sshd”未返回任何内容,“which ssh”返回

  1. /usr/bin/ssh

修复后:'哪个sshd'返回

  1. /usr/sbin/sshd
yqyhoc1h

yqyhoc1h15#

如果您能够ping而不能ssh,那么它就是一个防火墙。默认情况下,18.4上的防火墙(不确定其他版本)处于打开状态,并且只允许端口8080。
这是你怎么修的
https://linuxconfig.org/how-to-enable-disable-firewall-on-ubuntu-18-04-bionic-beaver-linux

相关问题