Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-26-2012, 12:32 AM   #1
Registered: Feb 2011
Posts: 141

Rep: Reputation: 10
Cannot connect through ssh

Everything seems to be configured correctly, but when trying to connect, using:
ssh -v localhost
I get
OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [] port 22.
debug1: Connection established.
debug1: identity file /home/janis/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-4096
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-4096
debug1: identity file /home/janis/.ssh/id_rsa-cert type -1
debug1: identity file /home/janis/.ssh/id_dsa type -1
debug1: identity file /home/janis/.ssh/id_dsa-cert type -1
debug1: identity file /home/janis/.ssh/id_ecdsa type -1
debug1: identity file /home/janis/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-7ubuntu1
debug1: match: OpenSSH_5.8p1 Debian-7ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
Key is identified, everything seems to be OK.

Tested if ssh server is working with
ps -A | grep sshd
681 ?        00:00:00 sshd
All is cool.

Tested if sshd is listening on port 22 with
sudo ss -lnp | grep sshd
0      128                           :::22                           :::*      users:(("sshd",681,4))
0      128                            *:22                            *:*      users:(("sshd",681,3))
All is cool.

Tested to connect using actual IP too, the same result!

Why is Peer(Server) resetting the connection?
Old 01-26-2012, 01:26 AM   #2
LQ Guru
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,037

Rep: Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407Reputation: 1407

at first glance it looks like a ssh protocol 1 vs protocol 2 problem.

Have you tried reading the log file for messages from sshd?

grep sshd /var/log/auth.log
Old 01-26-2012, 01:52 AM   #3
Registered: Feb 2011
Posts: 141

Original Poster
Rep: Reputation: 10
Thanks for the answer!

Yes I did notice too that it is going into compatibility mode for version 2 protocol and it looked suspicious! Thanks for pointing out and reminding me of that and where to look further.

Last edited by splintercdo; 01-26-2012 at 01:54 AM.
Old 01-26-2012, 08:33 PM   #4
Registered: Feb 2011
Posts: 141

Original Poster
Rep: Reputation: 10
Finally I solved it! Took me long enough. Was sitting, correcting my own mistakes and understanding how does Linux and ssh work for 4 hours

1. It wasn't protocol v.1 vs v.2 problem.

2. What I did to make peer reset connection was I did not understood that the keys which are generated in path of ssh itself(keys are for registration of accepted hosts) does not have any relation to authentication keys. Silly thing what I did was I removed those keys from /etc/ssh. (gladly I was smart enough to put them in sub folder for insurance and it paid off, was able to play with them later on.) And logically, that was the reason why peer was resetting connection, because host did not had allowance to connect to the server!

3. After that I had to solve the puzzle why is sshd rejecting my private key and again my mistake, when setting up for some reason I made folder named authorized_keys in my ~/.ssh and paste there the public authentication key. The correct way to set up public key information was instead of making folder - make file with the same name authorized_keys, open public key file, copy content of it and paste it into authorized_keys!

I hope that at least some experienced Linux admins have a good laugh at this!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Initiate ssh tunnel to connect to ssh? brianmcgee Linux - Security 2 09-07-2011 10:07 AM
Able to connect via SSH but not able to connect via web port 80 Orange Sunshine Linux - Server 9 04-03-2010 07:11 PM
how to use ssh to connect to xp bhert SUSE / openSUSE 10 09-20-2006 11:41 AM
iptables help! DROP ssh port, but allow to connect to ssh if from 2222 port kandzha Linux - Networking 4 09-13-2006 09:10 AM
ssh + pop3 with kmail: Could not connect to host localhost, but ok without ssh Emmanuel_uk Linux - Networking 0 07-20-2006 04:56 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration