在Ubuntu中ssh报错: connect to host localhost port 22: Connection refused 解决办法

【已解决】ssh localhost报错ssh: connect to host localhost port 22: Connection refused 从远程要连接的服务器端,修改了当前用户的密码(这里是重新设置为了原本的密码,换成新的密码也可以)之后,输入密码可以继续登陆了。但是还是不可以免密登录,说明之前配置的相关密钥设置文件不可用了,后面重新在本地使用ssh-keygen命令生成了新的密钥,然后更换了服务器的密钥文件内容,之后可继续免密登录了。 阅读详情
AI摘要

在搭建Hadoop 2.5伪分布集群时遇到ssh连接localhost 22端口被拒绝的问题。解决方法包括检查ssh服务状态,尝试重启sshd服务,并处理openssh-server的依赖问题。

     本人最近在Ubuntu 14.04上搭建Hadoop 2.5伪分布集群时偶然遇见ssh: connect to host localhost port 22: Connection refused 问题,尝试多种办法,最终得以解决,下面由我细细道来~~
      安装既定步骤进行完hadoop相关配置后,运行$ ./sbin/start-dfs.sh命令时终端显示如下:

➜  hadoop  ./sbin/start-dfs.sh 
Starting namenodes on [localhost]
localhost: ssh: connect to host localhost port 22: Connection refused
localhost: ssh: connect to host localhost port 22: Connection refused
Starting secondary namenodes [0.0.0.0]
0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
  

      怀疑ssh服务未启动,于是$ service sshd restart

➜  hadoop  service sshd restart
sshd: unrecognized service

      居然没有sshd服务,于是查了一下,本机初始状态安装的是openssh, 也不存在/etc/init.d/ssh这玩意儿,不能忍。于是怀疑本机22端口未开启,于是:

➜  hadoop  sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
➜  hadoop  ssh localhost                                      
ssh: connect to host localhost port 22: Connection refused

       还是不行!果断Google了一番(嘿嘿,个人热衷Google搜索,某度不敢恭维,在天朝当然得翻墙),当然搜了一圈,很多博客或论坛上的答复基本都是ps看是否启动ssh服务,然后重启。本人ssh登录公司服务器一点问题没有,登录localhost居然报错,于是怀疑子openssh安装可能出现问题,可能是openssh-server或者openssh-client,于是一股脑全部重装试试:

➜  hadoop  sudo apt-get install openssh-client openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-client is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 openssh-server : Depends: openssh-client (= 1:6.6p1-2ubuntu1)
E: Unable to correct problems, you have held broken packages.




       说openssh-server依赖于openssh-client,这是神马情况??于是:

➜  hadoop  sudo apt-get install openssh-client   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-client is already the newest version.
The following packages were automatically installed and are no longer required:
  libxcb-randr0 libxcb-render-util0 libxcb-xkb1 mysql-common-5.6
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

      于是怀疑可能是libxcb-randr0、libxcb-render-util0、 libxcb-xkb1、 mysql-common-5.6这几个东东在作怪,于是:


➜  hadoop  sudo apt-get clean
➜  hadoop  sudo apt-get autoremove
➜  hadoop  sudo apt-get update
Hit http://www.rabbitmq.com testing InRelease                                  
Ign http://us.archive.ubuntu.com trusty InRelease                              
Ign http://get.docker.io docker InRelease                                      
Ign http://ppa.launchpad.net trusty InRelease                                  
Ign http://extras.ubuntu.com trusty InRelease                                  
Hit http://us.archive.ubuntu.com trusty Release.gpg                            
Hit http://extras.ubuntu.com trusty Release.gpg                                
Ign http://ppa.launchpad.net trusty InRelease                                  
Hit http://www.rabbitmq.com testing/main amd64 Packages                        
Hit http://us.archive.ubuntu.com trusty Release                                
Hit http://extras.ubuntu.com trusty Release                                    
Ign http://ppa.launchpad.net trusty Release.gpg  
......

➜  hadoop  sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

      再次重装openssh-server:

➜  hadoop  sudo apt-get install -y openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 openssh-server : Depends: openssh-client (= 1:6.6p1-2ubuntu1)
E: Unable to correct problems, you have held broken packages.

      还是木有解决,重装openssh-client:

➜  hadoop  sudo apt-get install --reinstall openssh-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reinstallation of openssh-client is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

       于是继续在网上,看到一篇博客http://blog.csdn.net/feliciafay/article/details/6561414,大概意思是openssh-server依赖openssh-client,然后openssh-client依赖openssh-server,如此循环,博主最终把问题解决了,但我个人不能接受如此复杂的解决办法。于是找了另一篇博客http://www.cnblogs.com/xiaowenhu/p/3185631.html,即在安装openssh-client时候指定其版本,于是得到了启发,再次尝试:

➜  hadoop  sudo apt-get install openssh-client=1:6.6p1-2ubuntu1 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libpam-ssh keychain monkeysphere
The following packages will be DOWNGRADED:
  openssh-client
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 566 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main openssh-client amd64 1:6.6p1-2ubuntu1 [566 kB]
Fetched 566 kB in 19s (28.8 kB/s)                                              
dpkg: warning: downgrading openssh-client from 1:6.6p1-2ubuntu2 to 1:6.6p1-2ubuntu1
(Reading database ... 195887 files and directories currently installed.)
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu1) over (1:6.6p1-2ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up openssh-client (1:6.6p1-2ubuntu1) ...

        openssh-client安装正确,至少版本正确,再次安装openssh-server:

➜  hadoop  sudo apt-get install openssh-server                  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libck-connector0 ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
  rssh molly-guard monkeysphere
The following NEW packages will be installed:
  libck-connector0 ncurses-term openssh-server openssh-sftp-server
  ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 616 kB of archives.
After this operation, 3,420 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main openssh-sftp-server amd64 1:6.6p1-2ubuntu1 [34.1 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main openssh-server amd64 1:6.6p1-2ubuntu1 [319 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 B]
Fetched 616 kB in 10s (61.1 kB/s)                                              
Preconfiguring packages ...
Selecting previously unselected package libck-connector0:amd64.
(Reading database ... 195887 files and directories currently installed.)
Preparing to unpack ...bck-connector0_0.4.5-3.1ubuntu2_amd64.deb ...
Unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...
Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu1) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu1) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ...
Unpacking ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Setting up ncurses-term (5.9+20140118-1ubuntu1) ...
Setting up openssh-sftp-server (1:6.6p1-2ubuntu1) ...
Setting up openssh-server (1:6.6p1-2ubuntu1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 10352
Setting up ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...

      不再报之前的错!好像可以了诶~~
      再次$ ssh localhost:

➜  hadoop  ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is 04:93:aa:b3:9c:32:bd:96:4f:c1:bf:78:19:f8:5b:e6.
Are you sure you want to continue connecting (yes)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-36-generic x86_64)

 * Documentation:  https://help.ubuntu.com/


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

      成!功!了~

       总结,其实仔细分析错误原因,直观点分析其原因就对了,而且个人感觉openssh不太好用,需要自己安装或者更新,容易走弯路。不过问题解决了是最重要的,希望各位同学不再因此走弯路咯~~

[附源码]计算机毕业设计-Steam游戏平台系统论文Springboot程序 项目运行环境配置:(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。项目技术:等等组成,B/S模式 + Maven管理等等。环境需要1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可4. 阅读详情

相关推荐

功率电感的设计步骤

学习视频原链接截图1截图2。

qq_32419593的博客 4918

ssh: connect to host localhost port 22: Connection refused解决方法

在用ssh远程登陆Ubuntu Server时遇到如下问题: ssh: connect to host 192.168.36.15 port 22: Connection refused   解决: 1.检查是否安装了openssh-server ps -e|grep ssh   如果只出现了一个ssh,说明没有安装可以自行上网解决,一般Ubuntu最小版是没有默认安装的。 2.ss...

Bill_yin22的博客 6万+

保姆级教程:用AdGuard DNS代理实现全设备广告过滤(含Win/Mac/安卓/iOS配置)

本文提供了一份详尽的AdGuard DNS代理配置指南,帮助用户在全设备(Win/Mac/安卓/iOS)上实现广告过滤。通过系统级DNS设置,AdGuard能有效拦截广告、跟踪器和恶意网站,提升隐私保护和浏览效率。教程涵盖原理说明、各平台配置步骤及高级优化技巧,适合不同技术水平的用户。

weixin_42656416的博客 900

ssh: connect to host localhost port 22: Connection refused

今天本机安装hadoop 时,遇到一个问题,配置 ssh 登录权限失败 xxx@yyy:/opt/hadoop$ ssh localhost ssh: connect to host localhost port 22: Connection refused 百度搜索了好多文章都没能搞定,最后还是通过 bing 搜索(国际版) 搞定的,这里分享一下。 1 确认 OpenSSH server 是否安装 sudo apt list --installed | grep openssh-server 如果有如

mba1398的博客 4万+

从AMCL到SLAM Toolbox:在Nav2中实现高精度纯定位的实践指南

本文详细介绍了从AMCL迁移到SLAM Toolbox纯定位模式的实践指南,帮助开发者在Nav2中实现高精度定位。通过对比AMCL与SLAM Toolbox的性能差异,提供环境配置、参数调优、Nav2集成等关键步骤,显著提升机器人在动态环境中的定位精度和重定位效率。

weixin_29292535的博客 157

05 SAP CPI 访问第一个CPI接口

其中的clientid的值可作为Basic验证的用户名,clientsecret的值可作为Basic验证的密码。点击SEND按钮,可看见返回状态为200 OK。在04中,我们得到TOKEN令牌。POSTMAN向下滚动。点击按钮获取token。

SAP CPI 672

ssh:connect to host localhost port 22: Connection refused解决方法

虚拟机:master,slave4 环境:Ubuntu16.04 在配置master免密登录slave4时报了这个错误ssh:connect to host localhost port 22: Connection refused 解决方法: 1.检查是否安装了openssh-server,使用命令ps -e|grep sshd,如果出现了sshd,则说明安装了,反之则没安装。 结果发现...

lyc0424的博客 2万+

insightface scrfd人脸检测测试

pip install mmdet 自动安装mmcv win10上可以,服务器上没成功

jacke121的专栏 4033

LINUX开启ssh服务,报错:ssh: connect to host 192.168.0.101 port 22: Connection refused

Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因可能是ssh-server未安装或者未启动。 提示:ubuntu 11.10 默认安装openssh-client,但是没有安装server(其他博主说的,未验证);博主的Ubuntu是16.10,测试发现 openssh-client 和openssh-server 均没有安装 运行 ps -.

apollo_miracle的博客 2万+

强化学习从基础到进阶-案例与实践[4]:深度Q网络-DQN、double DQN、经验回放、rainbow、分布式DQN

强化学习从基础到进阶-案例与实践[4]:深度Q网络-DQN、double DQN、经验回放、rainbow、分布式DQN

丨汀、的博客 2072

Orange3实战教程:实例---文本分类

我们可以使用预测模型按作者、类型、情感等对文档进行分类。在此工作流中,我们根据文档的Aarne Thompshon Uther索引对文档进行归类,这是故事的主题定义。我们使用两个简单的学习器,Logistic回归和朴素贝叶斯,两者都可以在诺谟图中检查。然后再从可视化分类中添加列线图组件,观察哪些词对逻辑回归最重要。也可以尝试使用在朴素贝叶斯模型上,并编辑连线属性。再从模型中添加朴素贝叶斯模型,以尝试不同的学习器。

err2008的专栏 393

Ubuntu 安装配置SSH(ssh: connect to host localhost port 22: Connection refused问题的解决)

目录应用场景错误信息基础知识配置过程 应用场景 Hadoop搭建伪集群启动和关闭服务时ssh报错,需要手动安装ssh服务。 错误信息 基础知识 SSH是指Secure Shell,是一种安全的传输协议,Ubuntu客户端可以通过SSH访问远程服务器 。 SSH分客户端openssh-client和openssh-server 如果你只是想登陆别的机器的SSH只需要安装openssh-client(ubuntu有默认安装,如果没有则sudoapt-get install openssh-client),如果

ANDEL2001的博客 4120

BES2700的PMU

BES2700ZP-BES2700芯片的PMU架构分析摘要:本文档分析了BES2700芯片的电源管理单元(PMU)架构。实际应用中仅需为VBAT引脚供电,其余电源均由芯片内部PMU提供。文档包含架构示意图、问题列表和参考链接,涉及PMU工作原理、外部供电要求等关键技术点。待解决问题包括具体供电参数和内部电源转换机制等。通过添加日志信息和代码片段,为开发人员提供了调试PMU功能的实用方法。

云淡风轻 138

Ubuntu 配置SSH登录时报错:ssh: connect to host localhost port 22: Connection refused 以及 openssh-server 安装失败

在Ubuntu 16.04 上面配置SSH免密码登录的时候,当使用 ssh-keygen -t rsa cp id_rsa.pub authorized_keys 命令生成公钥和私钥之后,通过 ssh localhost 命令连接本机的时候出现一下错误: ssh: connect to host localhost port 22: Connection refused 出现这个的...

khxu666的博客 7020

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

LINUX开启ssh服务,报错:ssh: connect to host 192.168.6.129 port 22: Connection refused

Ubuntu下测试ssh时使用ssh localhost 命令,出现错误提示connect to host localhost port 22:Connection refused 造成这个错误的原因可能是ssh-server未安装或者未启动。ubuntu 11.10 默认安装openssh-client,但是木有安装server 运行 ps -e | grep ssh,查看是否有sshd进程 如...

qq_20867981的博客 7万+

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

ubuntu16.04 ssh连接出现connect to host localhost port 22: Connection refused 解决办法

首先我报错是因为改动了ssh的系统环境配置而导致的web端监听不响应,进而展开了一系列的迷茫操作。 ubuntu16.04启动SSH服务报: Job for ssh.service failed because the control process exited with error codesee systemctl status ssh.service and journalctl -xe for details. 然后按照提示输入: systemctl status sshd.service 表示给

victory0808的博客 1525

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Ubuntu 安装配置SSH时 (ssh: connect to host localhost port 22: Connection refused):

Ubuntu 安装配置SSH时 报错 (ssh: connect to host localhost port 22: Connection refused): 百度百科: SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定;SSH 为建立在应用层基础上的安全协议。SSH 是较可靠,专为远程登录会话和其他网络服务提供安全性的...

文轩 726

[Hadoop] Ubuntu localhost: ssh: connect to host localhost port 22: Connection refused

问题描述在Ubuntu下启动hadoop的hdfs时出现:hadoop@ubuntu:~/hadoop-2.8.1$ sbin/start-dfs.sh Starting namenodes on [localhost] localhost: ssh: connect to host localhost port 22: Connection refused localhost: ssh: con

Nothing is impossible 6965

ssh: connect to host localhost port 22: Connection refused问题

初次安ubantu, 连接ssh时出现报错:connect to host localhost port 22: Connection refused 解决办法参考:https://www.linuxidc.com/Linux/2015-01/112045.htm

shun201207的博客 1175

ssh: connect to host localhost port 22: Connection refused(ubuntu14.04_LTS)

安装hadoop时需要先安装无密钥ssh登陆。到ssh localhost这一步时却报出如下的错误:ssh: connect to host localhost port 22: Connection refused在网上多翻搜索,总结原因大概3个如下 1、ssh-server未安装或者未启动 这个问题可用2条语句一次性解决。sudo apt-get remove openssh-server

BetterWorld的专栏 7142

报错?!-20170213-ssh: connect to host localhost port 22: Connection refused

Problemssh: connect to host localhost port 22: Connection refused Solutionsudo apt-get install openssh-serverMarkUbuntu 安装配置SSH(ssh: connect to host localhost port 22: Connection refused问题的解决)

Blogging on ZF 1075

使用Docker操作“ssh localhost”时出现“connect to host localhost port 22: Connection refused”问题的解决

Ingredient: Docker: Hadoop: 想在Docker容器中安装Hadoop,设置系统无密码登录时,配置了公钥私钥之后,操作: ssh localhost 却仍然报错: root@becdadab2db1:/# ssh localhost ssh: connect to host localhost port 22: Connection refused 后来发现竟...

干勾鱼的CSDN博客 1万+

远程连接报错:connect to localhost port 22: Connection refused

1.如果远程连接的是mac电脑: 确保mac电脑的远程登陆的权限打开(如果mac电脑不允许远程登陆,那肯定无法远程登陆) 第一步:打开系统偏好设置 第二步:选择共享 第三步:将远程连接选项选中,同时将允许访问的选项选择为所有用户 2.如果远程连接的是ubuntu电脑 第一步:在终端下输入:ps -e|grep ssh 第二步:如果输出没有或者只有一个ssh-agent就说明没安装openssh-...

DedicationTechnology 7726

ssh:connect to host localhost port 22: Connection refused

检查是否安装了openssh-server,使用命令ps -e|grep sshd, 出现了sshd,则安装了,否则则没安装,没安装则输入命令行: sudo apt-get install openssh-server 安装之后就可以了。 ...

weixin_43484977的博客 226
下一篇: Ubuntu 14.04 Chrome中文乱码解决办法
bluecom24
博客等级 码龄15年 2粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值