在ubuntu中配置SSH(解决connect to host localhost port 22: Connection refused问题)

update: 下面这篇文章距离现在比较久了,不一定适合大家机器现在的情况了,如果不能成功解决问题请见谅。

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

简单地说

 

配置hadoop时必须的一步就是保证ssh是联通的。如果你的ubuntu中没有安装ssh,具体的安装步骤是这样的:

 

1https://launchpad.net/ubuntu/lucid/i386/openssh-client/1:5.3p1-3ubuntu3

下载文件” openssh-client_5.3p1-3ubuntu3_i386.deb 并在终端中安装。

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

2https://launchpad.net/ubuntu/lucid/i386/openssh-server/1:5.3p1-3ubuntu3

下载文件” openssh-server_5.3p1-3ubuntu3_i386.deb”并在终端中安装。
sudo dpkg -i openssh-server_5.3p1-3ubuntu3_i386.deb

 

3https://launchpad.net/ubuntu/lucid/i386/ssh/1:5.3p1-3ubuntu3

下载文件”ssh_5.3p1-3ubuntu3_all.deb”并在终端中安装。
sudo dpkg -i ssh_5.3p1-3ubuntu3_all.deb

 

 

 

复杂地说

 

我尝试了很多错误路线,最后终于找到了正确方式,现在把我走过的弯路也记录一下:

 

hadoop配置的过程中,前提条件之一是保证ssh是配置好的。使用这个命令,hadoopr@ubuntu:~$ ssh localhost

得到了如下的信息

ssh: connect to host localhost port 22: Connection refused
这意味着ssh不能联通成功。不联通的理由可以有很多,如防火墙设置问题,如ssh没有被安装。我的连防火墙都没有,所以应该是ssh安装的问题。

 

于是现在安装ssh
网上搜到信息说,安装ssh应该使用这样的命令,如下

hadoopr@ubuntu:~$ 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

hadoopr@ubuntu:~$ 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发现了一个地址,https://launchpad.net/ubuntu/lucid/i386/ssh/1:5.3p1-3ubuntu3,网页方式直接下载了一个对应文件。”ssh_5.3p1-3ubuntu3_all.deb”
本来我觉得只要安装它应该就可以了,于是

hadoopr@ubuntu:~/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。这样岂不是死循环了。

 

于是又去了https://launchpad.net/ubuntu/lucid/i386/ssh/1:5.3p1-3ubuntu3这个网址,仔细阅读。

发现,其实网上说得很明白,我刚才自己没有看清楚。要成功地装ssh需要三步。

第一步,在https://launchpad.net/ubuntu/lucid/i386/openssh-client/1:5.3p1-3ubuntu3下载文件并安装。

第二步,在https://launchpad.net/ubuntu/lucid/i386/openssh-server/1:5.3p1-3ubuntu3下载文件并安装。

第三步,在https://launchpad.net/ubuntu/lucid/i386/ssh/1:5.3p1-3ubuntu3下载文件并安装。

剩下的事儿就好办了。下载安装即可。

下载并安装第一个文件

hadoopr@ubuntu:~/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 ...

下载并安装第二个文件

hadoopr@ubuntu:~/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 ...

下载并安装第三个文件

hadoopr@ubuntu:~/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) ...

最后试了试,成功。

hadoopr@ubuntu:~/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,database,processing,triggers)