现在的位置: 首页 > 综合 > 正文

ssh 安装

2013年02月08日 ⁄ 综合 ⁄ 共 5214字 ⁄ 字号 评论关闭

  • 安装配置SSH

  (1)下载安装SSH:同样在命令行输入下面命令安装SSH

  sudo apt-get install ssh

  (2)配置无密码登录本机:在命令行输入下面两条命令

  ssh-keygen -t dsa -P " -f ~/.ssh/id_dsa

  cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

  (3)验证SSH是否安装成功

  输入 ssh localhost 。如果显示本机登录成功就表明安装成功。

  •    配置ssh无密码登录到localhost却仍要输入密码,在网上搜索解决方法后找到如下方法:

修改.ssh/authorized_keys的权限,去除组的可写权限

实施后仍无法无密码登录。出现Agent admitted failure to sign using the key错误。

搜索该错误,找到如下方法:

ssh-add ~/.ssh/id_rsa

执行后成功无密码登录。

PS:

在OPENSUSE下ssh localhost 出现如下错误

ssh: connect to host localhost port 22: Connection refused

是因为没有安装sshd并且防火墙阻止导致的。

安装yast2-sshd,并在yast中打开防火墙设置,添加自定义规则,允许127.0.0.1访问目标端口22。

然后运行/etc/init.d/sshd restart后再按照hadoop官网步骤配置即可。

  1. 简单地说

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

1       到 https://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

2        到https://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

3       到https://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

     2. 复杂地说

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

在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.

我晕,一个下午就卡在提示的The authenticity of host 'localhost (::1)' can't be established.这句话上,原来要打个“yes”就能走下去。

抱歉!评论已关闭.