11

I can't SSH localhost. I have installed OpenSSH server as well on my Ubuntu 12.04 LTS (32 bit).

connected to net (ip : 192.168.1.2) installed hadoop, running hadoop for local machine.

Here's what I get :

root@kunal-Extensa-4620:/# ssh -vvv localhost
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "localhost" from file "/root/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
  • check if port 22 is open for incoming connections at your end – Registered User Jun 14 '13 at 11:06
  • sudo ss -lnp | grep sshd # results in LISTEN 0 128 :::22 :::* users:(("sshd",556,4)) LISTEN 0 128 :22 :* users:(("sshd",556,3)) dear, its open and listening. – ASCIIbetical Jun 14 '13 at 11:16
  • what is the exact message you get on scree when you do ssh user@localhost – Registered User Jun 14 '13 at 11:18
  • What does the server log say on your connection attempt? See /var/log/syslog and /var/log/auth.log. – gertvdijk Jun 14 '13 at 11:23
  • what is the exact message you get on scree when you do ssh user@localhost you typed ssh -vvv localhost it doesnt makes any sense ssh -vvv user@localhost should be the thing – Registered User Jun 14 '13 at 11:24
  • remove and reinstall OpenSSH not sure but this can fix this problem – Registered User Jun 14 '13 at 11:29
  • Perhaps PermitRootLogin is set to false in your /etc/ssh/sshd_config? – gacrux Jun 14 '13 at 11:31
  • sshd_config file is totally empty ? normal i guess not ? Y – ASCIIbetical Jun 14 '13 at 11:32
  • When i do ssh user@localhost, i get the same message what i get earlier. the same log at terminal which i posted in my question. i have tried that once removing and reinstalling openssh, thanks – ASCIIbetical Jun 14 '13 at 11:35
  • Though i wonder Y SSHD_CONFIG IS EMPTY ?? I opened it via gedit,and it came out complete blanks like a white sheet ?nothing written at all ? – ASCIIbetical Jun 14 '13 at 11:39
  • Thanks all, i guess its running now. i removed, purged and reinstalled. here's the output :ssh localhost root@localhost's password: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686)
    • Documentation: https://help.ubuntu.com/

    Last login: Fri Jun 14 17:15:56 2013 from localhost B: command not found B: command not found D: command not found D: command not found D: command not found D: command not found

    – ASCIIbetical Jun 14 '13 at 11:55

3 Answers3

12

In the comments it appeared that your OpenSSH server configuration file (/etc/ssh/sshd_config) is empty. Reinstall the configuration file by purging and reinstalling:

  1. Remove the configuration file:

    sudo rm /etc/ssh/sshd_config
    
  2. purge:

    sudo apt-get purge openssh-server
    
  3. install:

    sudo apt-get install openssh-server
    

This may not work, instead, then follow: How can I restore configuration files?

gertvdijk
  • 67,947
  • Thanks all, i guess its running now. i removed, purged and reinstalled. here's the output :ssh localhost root@localhost's password: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686) * Documentation: help.ubuntu.com Last login: Fri Jun 14 17:15:56 2013 from localhost B: command not found B: command not found D: command not found D: command not found D: command not found D: command not found – ASCIIbetical Jun 14 '13 at 11:55
0

You connect using the following command

ssh username@127.0.0.1

Change username to whatever user is available on that computer

muru
  • 197,895
  • 55
  • 485
  • 740
Meer Borg
  • 4,963
  • Hello Meer Borg, i did what you asked me to do. ran ssh -vvv kunal@127.0.0.1 but alas, sorry to say, i got the same log on terminal which i was getting earlier. till the last 2nd line, it goes like this : debug1: SSH2_MSG_KEXINIT sent Read from socket failed: Connection reset by peer and then the same error. Thanks again. though, i am open to suggestions if any. – ASCIIbetical Jun 14 '13 at 11:10
  • Specifying the username explicitly does not make any difference here. ssh will use the current username by default. – gertvdijk Jun 14 '13 at 11:22
  • @KunalSangwan Check the /var/log/auth.log file to see if there is anything that is logged at the time you try to log into that command cat /var/log/auth.log | tail – Meer Borg Jun 14 '13 at 11:45
  • Thanks all, i guess its running now. i removed, purged and reinstalled. here's the output :ssh localhost root@localhost's password: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686) * Documentation: help.ubuntu.com Last login: Fri Jun 14 17:15:56 2013 from localhost B: command not found B: command not found D: command not found D: command not found D: command not found D: command not found – ASCIIbetical Jun 14 '13 at 11:56
0

In you log I see following message debug3: load_hostkeys: loading entries for host "localhost" from file "/root/.ssh/known_hosts"

so that means machine is trying to look for hosts and more over connection has been attempted check for ssh logs and post here (that will reveal if any connection reached localhost or not)

also check if port 22 is open for incoming connections at your end because it seems that port 22 is closed at your end for incoming connections check if by the way you are running any kind of firewall (IPTABLES) etc which blocks it

what is the exact message you get on screen when you do ssh user@localhost you typed ssh -vvv localhost it doesnt makes any sense ssh -vvv user@localhost should be the thing

  • my port 22 is open here's what i got : netstat -anp | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 556/sshd
    tcp6 0 0 :::22 :::* LISTEN 556/sshd
    – ASCIIbetical Jun 14 '13 at 11:26
  • try removing and reinstalling OpenSSh – Registered User Jun 14 '13 at 11:30
  • Though one thing : /etc/ssh/sshd_config is empty ? is that normal ? – ASCIIbetical Jun 14 '13 at 11:30
  • @KunalSangwan No. How did that happen? Please add such info to your question! – gertvdijk Jun 14 '13 at 11:31
  • did once removed and reinstalled open ssh – ASCIIbetical Jun 14 '13 at 11:31
  • @KunalSangwan Then purge instead of regular remove action! This will reinstall configuration files. – gertvdijk Jun 14 '13 at 11:32
  • @gertvdijk can you be kind enough to specify the command please. – ASCIIbetical Jun 14 '13 at 11:38
  • Though i wonder Y SSHD_CONFIG IS EMPTY ?? I opened it via gedit,and it came out complete blanks like a white sheet ?nothing written at all ? – ASCIIbetical Jun 14 '13 at 11:40
  • Thanks all, i guess its running now. i removed, purged and reinstalled. here's the output :ssh localhost root@localhost's password: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-29-generic-pae i686) * Documentation: help.ubuntu.com Last login: Fri Jun 14 17:15:56 2013 from localhost B: command not found B: command not found D: command not found D: command not found D: command not found D: command not found – ASCIIbetical Jun 14 '13 at 11:57