Removing and reinstalling SSH

I’ve been trying to remotely connect via ssh with no password for a while now – I think ive managed to figured out how to do it now, but in the process of sorting it out I think ive removed things that I wasn’t supposed to.

For example

Now when I connect from Comp1 to Comp2 ssh [ip address] I get this error message: Host key verification failed.

And when I connect from Comp2 to Comp1 ssh [ip address] I get this error message: ssh_exchange_identification: Connection closed by remote host.

I’ve removed everything out of the /~ssh directory on both machines.

I want to basically reinstall openssh and start again. What’s the best way around it? I’ve tried rpm –e opensshpackagename.rpm but it has a few dependencies such as
openssh-server,
openssh-client,
openssh-askpass
openssh-askpass-gnome.

Im running Fedora Core 3.

What’s the best way of tackling the problem?

Thanks


LVL 1
the_omnificAsked:
Who is Participating?
 
DonConsolioCommented:
try rebuilding your host keys
(if you don't know the location check "/etc/ssh/sshd_config"

e,g,
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
0
 
DonConsolioCommented:
remove $HOME/.ssh/known_hosts
0
 
the_omnificAuthor Commented:
I have done already on both machines
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
DonConsolioCommented:
try  "ssh -v Comp2" and check output (or post here if you do not understand it)
0
 
the_omnificAuthor Commented:
Comp1 to Comp2

[root@Test documents]# ssh -v 192.168.0.3
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for *
debug1: Connecting to 192.168.0.3 [192.168.0.3] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type 0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.9p1
debug1: match: OpenSSH_3.9p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Host key verification failed.
0
 
the_omnificAuthor Commented:
Comp 2 to Comp 1

[root@FILESERVER ~]# ssh -v 192.168.0.90
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.90 [192.168.0.90] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type 0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
ssh_exchange_identification: Connection closed by remote host
[root@FILESERVER ~]#

0
 
DonConsolioCommented:
looks like you deleted your ssh host key

either reinstall the rpm with the "--nodepends" option (or with "--force" if needed)

or regenerate your host key

example code:
        if ! test -f /etc/ssh/ssh_host_key ; then
            echo Generating /etc/ssh/ssh_host_key.
            ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''
        fi
        if ! test -f /etc/ssh/ssh_host_dsa_key ; then
            echo Generating /etc/ssh/ssh_host_dsa_key.
            ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
        fi
        if ! test -f /etc/ssh/ssh_host_rsa_key ; then
            echo Generating /etc/ssh/ssh_host_rsa_key.
            ssh-keygen -t rsa -b 1024 -f /etc/ssh/ssh_host_rsa_key -N ''
        fi
0
 
the_omnificAuthor Commented:
i removed the ssh directory and used the rpm -vi --force openssh-3.9p1-7.i386.rpm, rpm -vi --force openssh-clients-3.9p1-7.i386.rpm, rpm -vi --force openssh-server-3.9p1-7.i386.rpm commands... and im still getting:

[root@Test documents]# ssh -v 192.168.0.3
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.3 [192.168.0.3] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
ssh_exchange_identification: Connection closed by remote host

?
0
 
the_omnificAuthor Commented:
to be honest i didn't really know how to rebuild the hostkeys so i simply loaded Fedora on another machine and copied the /etc/ssh directory across to both machines and everything is configured fine. thanks for your prompt responses
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.