1. 程式人生 > >在ubuntu中配置SSH(解決connect to host localhost port 22: Connection refused問題)

在ubuntu中配置SSH(解決connect to host localhost port 22: Connection refused問題)

update: 下面這篇文章距離現在比較久了,不一定適合大家機器現在的情況了,如果不能成功解決問題請見諒。

————————————————————————————————————————————————————

簡單地說

配置hadoop時必須的一步就是保證ssh是聯通的。如果你的ubuntu中沒有安裝ssh,具體的安裝步驟是這樣的:

下載檔案” openssh-client_5.3p1-3ubuntu3_i386.deb並在終端中安裝。

sudo dpkg -i openssh-client_5.3p1-3ubuntu3_i386.deb

複雜地說

我嘗試了很多錯誤路線,最後終於找到了正確方式,現在把我走過的彎路也記錄一下

:

hadoop配置的過程中,前提條件之一是保證ssh是配置好的。使用這個命令,[email protected]:~$ ssh localhost

得到了如下的資訊

ssh: connect to host localhost port 22: Connection refused這意味著ssh不能聯通成功。不聯通的理由可以有很多,如防火牆設定問題,如ssh沒有被安裝。我的連防火牆都沒有,所以應該是ssh安裝的問題。

於是現在安裝ssh
網上搜到資訊說,安裝ssh應該使用這樣的命令,如下

[email protected]:~$ sudo apt-get install 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:5.3p1-3ubuntu3) but 1:5.3p1-3ubuntu5 is to be installed
E: Broken packages
仔細閱讀上面這對錯誤資訊。發現 openssh-server是需要在openssh-client安裝後才能安裝的。並且看來指定得openssh-client的版本是1:5.3p1-3ubuntu3.

於是,自然而然地想到要去安裝1:5.3p1-3ubuntu

[email protected]:~$ sudo apt-get install 1:5.3p1-3ubuntu3
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Couldn't find package 1:5.3p1-3ubuntu3
最後一句話說明,sudo apt-get install此路不通啊,於是換一條路。

在百度上搜索5.3p1-3ubuntu3得到的有用資訊非常少,在google上搜索5.3p1-3ubuntu3發現了一個地址,,網頁方式直接下載了一個對應檔案。”ssh_5.3p1-3ubuntu3_all.deb”
本來我覺得只要安裝它應該就可以了,於是

[email protected]:~/Downloads$ sudo dpkg -i ssh_5.3p1-3ubuntu3_all.deb

但是,讓人吐血的一步來了,

Selecting previously deselected package ssh.
(Reading database ... 127434 files and directories currently installed.)
Unpacking ssh (from ssh_5.3p1-3ubuntu3_all.deb) ...
dpkg: dependency problems prevent configuration of ssh:
 ssh depends on openssh-server; however:
  Package openssh-server is not installed.
dpkg: error processing ssh (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing: ssh
注意一下,它說 ssh depends on openssh-server; however:Package openssh-server is not installed.也就是說,剛才安裝openssh-server時它說需要openssh-client,現在安裝openssh-client了,它又說需要先裝openssh-server。這樣豈不是死迴圈了。

發現,其實網上說得很明白,我剛才自己沒有看清楚。要成功地裝ssh需要三步。

剩下的事兒就好辦了。下載安裝即可。

下載並安裝第一個檔案

[email protected]:~/Downloads$ sudo dpkg -i openssh-client_5.3p1-3ubuntu3_i386.deb
dpkg: warning: downgrading openssh-client from 1:5.3p1-3ubuntu5 to 1:5.3p1-3ubuntu3.
(Reading database ... 127436 files and directories currently installed.)
Preparing to replace openssh-client 1:5.3p1-3ubuntu5 (using openssh-client_5.3p1-3ubuntu3_i386.deb) ...
Unpacking replacement openssh-client ...
Setting up openssh-client (1:5.3p1-3ubuntu3) ...
Processing triggers for man-db ...

下載並安裝第二個檔案

[email protected]:~/Downloads$ sudo dpkg -i openssh-server_5.3p1-3ubuntu3_i386.deb
Selecting previously deselected package openssh-server.
(Reading database ... 127436 files and directories currently installed.)
Unpacking openssh-server (from openssh-server_5.3p1-3ubuntu3_i386.deb) ...
Setting up openssh-server (1:5.3p1-3ubuntu3) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
 * Stopping OpenBSD Secure Shell server sshd                                                              [ OK ]
ssh start/running, process 3822
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw ...
Processing triggers for man-db ...

下載並安裝第三個檔案

[email protected]:~/Downloads$ sudo dpkg -i ssh_5.3p1-3ubuntu3_all.deb
(Reading database ... 127454 files and directories currently installed.)
Preparing to replace ssh 1:5.3p1-3ubuntu3 (using ssh_5.3p1-3ubuntu3_all.deb) ...
Unpacking replacement ssh ...
Setting up ssh (1:5.3p1-3ubuntu3) ...

最後試了試,成功。

[email protected]:~/Downloads$ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is 0f:f5:b7:32:06:a3:3c:4c:de:fb:04:aa:8a:f2:2d:ee.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.


相關推薦

ubuntu配置SSH(解決connect to host localhost port 22: Connection refused問題)

update: 下面這篇文章距離現在比較久了,不一定適合大家機器現在的情況了,如果不能成功解決問題請見諒。 ———————————————————————————————————————————————————— 簡單地說 配置hadoop時必須的一步就是保證ssh是聯通

sshconnect to host localhost port 22: Connection refused解決方法

安裝hadoop的時候,需要配置ssh無密登入 執行ssh localhsot的時候會報錯: linux系統(centos6.4) ssh:connect to host localhost po

Ubuntu下使用ssh遠端登入時出現錯誤提示connect to host localhost port 22:Connection refused

1、Ubuntu下測試ssh時使用ssh localhost 命令,出現錯誤提示connect to host localhost port 22:Connection refused 造成這個錯誤的原因可能是ssh-server未安裝或者未啟動。ubuntu

ssh:connect to host localhost port 22: Connection refused

1.先徹底刪除ssh內容 sudo apt-get remove --purge openssh-server 2.重新安裝openssh-server sudo apt-get install openssh-server  (openssh-client可以不裝) 3.

ssh: connect to host localhost port 22: Connection refused

在ROS下執行ssh 指令時可能會碰到這樣的錯誤提示 ssh: connect to host localhost port 22: Connectionrefused 錯誤原因可能有三個: 1.sshd 未安裝 2.sshd未啟動 3.防火清 解決辦法: 1.確定安裝s

ssh: connect to host localhost port 22: Connection refused : 通過系統日誌排查問題

1. 配置好了ssh免登入,但登入的時候卻報拒絕連線 [[email protected] Desktop]$ ssh localhost ssh: connect to host localhost port 22: Connection refused 2.

mac connect to host localhost port 22: Connection refused

解決 問題 host color class body 遠程 得到 pen 在Mac OS X 10.10.5學習hadoop的過程中,輸入命令ssh localhost得到 ssh: connect to host localhost port 22: Connec

Git配置22端口,解決ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly

name 訪問 基於 .net article 自定義 一個 實現 背景 背景:私自搭建了Git服務器,而Git本身就是SSH進行連接的,而Git命令上默認只能通過22端口實現。 解決方法: 第一種: 在系統的用戶目錄下的文件夾:.ssh 如果該路徑下沒有confi

關於ssh: connect to host master port 22: Connection timed out問題的總結

最近在cnetos6.5系統上重新配置了hadoop-2.2.0,在配置叢集的ssh無祕鑰登入時,經常能碰到ssh: connect to host master port 22: Connection timed out的問題。現在對該問題做一下可能出現的問題的總結和解決

【流水】啟動hdfs的報錯ssh: connect to host master port 22: Connection timed out

報錯如下: [[email protected] sbin]$ ./start-dfs.sh 18/01/24 22:46:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library fo

<Linux> Ubuntu error: ssh: connect to host master port 22: No route to host lost connection

ror host input ssh端口 linu 就會 accept ssh ubuntu iptables當找到匹配的規則時,就會執行相應的動作,而不會向下繼續匹配。因為ssh端口開放的規則在all規則之後,所以永遠都不會匹配到,也就是ssh永遠被禁止。 root下執行

使用wifi ssh: connect to host hadoop000 port 22: No route to host

自動分配 pin route port 是否 size 問題 nec 配置 使用的wifi,在wifi下IP會自動分配。 先嘗試能否ping通,如果都無法ping通那先把IP配置那些先搞定ping通之後遇到此問題再來嘗試解決。 查看 /etc/hosts 中配置的 I

git clone(fatal: Authentication failed for 'http://XXX.git/'&&ssh:connect to host XXX port 22:超時)

問題描述: 第一天正式實習,專案組的人給我開放了遠端庫的許可權,然後就git clone(採用http的方式),成功。然後因為修改了一些內容,所以刪掉再次克隆,結果就出現了下面的錯誤。

CentOS系統出現錯誤--SSHconnect to host centos-py port 22: Connection refused

start 配置 下載 pan 要去 isp 執行 hostname openssh   我在第一次搭建自己的 hadoop2.2.0單節點的偽分布集成環境時遇到了此錯誤,通過思考問題和查找解決方案最終搞定了這個問題,其錯誤原因主要有以下幾種:   1)S

Ubuntu SSH - ssh: connect to host ****** port 22: Connection refused

Ubuntu SSH - ssh: connect to host ****** port 22: Connection refused OpenSSH is the premier connectivity tool for remote login with the SSH prot

【git 埠拒絕解決方案】ssh: connect to host github.com port 22: Connection refused

前言 前一陣兒,在公司同步github程式碼到本地的時候,爆出了這樣的一個錯誤ssh: connect to host github.com port 22: Connection refused。根據英文可以看出,ssh埠號被拒絕了,應該是被公司的網給禁掉了

解決ssh: connect to host github.com port 22: Connection refused

問題引入 當你在Linux環境下配置好git並連結到後,你想要把本地的程式碼上傳到github中。但是當你push的時候,會出現失敗的情況。 ssh [email protected] 使用上面的命令檢視詳細錯誤資訊,得到以下結果 解決方法 然後

Linux-ssh: connect to host 192.168.1.161 port 22: Connection refused

初學者利用ssh連線主機出現:一、檢查要連線的伺服器是否有ssh服務,如果沒有    centos6 為例(均已root角色執行)    1、安裝ssh服務:yum install openssh-server     2、啟動ssh服務:service sshd start

Ubuntu清理Network下Connect to Server的入口

connect to server入口列表檔案以xml格式存放在 ~/.config/nautilus/servers 中 用gedit或vi開啟~/.config/nautilus/servers, 刪除 某一對 bookmark 標籤之間的內容就可以刪除對應的conne

如何解決遠程連接mysql出現Can’t connect to MySQL server on (111 “Connection refused”)的問題

本地連接 遠程連接 content num working 是不是 class kcon firewall 如何解決遠程連接mysql出現Can’t connect to MySQL server on (111 “Connection refused”)的問題 開放My