Link to home
Start Free TrialLog in
Avatar of sriv1211
sriv1211

asked on

help logging into openssh

when i do   ssh localhost, i can't login (please see attached code)
root@Anand:/home/anand/Desktop# ssh localhost
Ubuntu 8.04.1
Password: 
Password: 
Password: 
root@localhost's password: 
Permission denied, please try again.
root@localhost's password: 
Permission denied, please try again.
root@localhost's password: 
Permission denied (publickey,password,keyboard-interactive).

Open in new window

Avatar of arnold
arnold
Flag of United States of America image

Root login via ssh is often disabled.  Check the sshd_config file which at times is in /etc/ssh.
Why do you need to ssh to local host?  If you are already on the system, use sudo bash to gain root access (if it is configured) or use su -, but note that the root account on ubuntu is often limited to console login.
ASKER CERTIFIED SOLUTION
Avatar of sriv1211
sriv1211

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
try ssh -v ...... to see a little bit more.
I guess you have a permission problem with one of the .ssh - directories/files.
Norbert
Avatar of sriv1211
sriv1211

ASKER

Below is my ssh version thing. would you be able to tell me what to do next
ssh -v
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
usage: ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-i identity_file] [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-w local_tun[:remote_tun]] [user@]hostname [command]

Open in new window

Sorry, I meant to say
ssh -v localhost
to see why your login doesnt work.
Norbert
below is my code:
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/anand/.ssh/identity type -1
debug1: identity file /home/anand/.ssh/id_rsa type -1
debug1: identity file /home/anand/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/anand/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 8.04.1
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Offering public key: /home/anand/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Trying private key: /home/anand/.ssh/identity
debug1: Trying private key: /home/anand/.ssh/id_rsa
debug1: Next authentication method: keyboard-interactive
Password: 

Open in new window

Now, I'm a bit confused.
Is your goal to login without password?
If yes, did you ever generate the appropriate private/public key pair(s) (ssh-keygen)?
Did you enter a password after having been prompted? What happened?
If your password is wrong, how could you ever login as root?
root's home is /home/anand, right?
1: my goal is to just login, password or not
2. i did not use the ssh keygen
3. the home of root is /home/root, but i am root when i type in sudo su. until then i am /home/anand
thanks
I have to leave now. Will be thinking it over till tomorrow.
Perhaps I'll have another look later this evening.
So long!
In order to login without a password, you have to run keygen  for rsa1, rsa, dsa (as woolmilkproc mentioned) while under the anand account.
This will add three keys under the /home/anand/.ssh.
The other part of the key is the public key (identity*.pub). You need to append the identity.pub into /home/root/.ssh/authorized_keys and identity_rsa.pub and identity_dsa.pub into /home/root/.ssh/authorized_keys2.

Depending on whether you setup a passphrase when generating the keys (keygen) you would either be prompted for the passphrase or permitted to login.
would you be able to show me an example for this. thanks
When you are loged in as anand:
run:
ssh-keygen -b 1024 -t rsa1
ssh-keygen -b 1024 -t rsa
ssh-keygen -b 1024 -t dsa
Do not set a passphrase if you do not want to provide it anytime you login. i.e. when prompted for the passphrase hit enter and enter to confirm.  If you do wish to set a passphrase type it in twice.
When the above are complete, within the .ssh directory you will have three files with the .pub suffix.
http://www.manpagez.com/man/1/ssh-keygen/

run sudo bash.
make sure /home/root/.ssh exists if it does not create it.
cat /home/anand/.ssh/identity.pub >> /home/root/.ssh/authorized_keys
cat /home/anand/.ssh/id_*.pub >> /home/root/.ssh/authorized_keys2
make sure that the /home/root/.ssh/authorized* have permissions for other,world read access(644).

exit the sudo session and try the ssh -v root@localhost.  You would either login or you will be prompted for a passphrase if one was set when the key generated.
The verbose will indicate which key was used.
running ssh -v -1 root@localhost will force the RSA key login.
hi, i tried what you said, but it came up with:
do you know why?
thanks
Host key verification failed.

Open in new window

Hi again,
glad to see some progress.
Host key verification:
Please edit the file 'known_hosts' under the .ssh directory and delete the corresponding key
(the one beginning with [hostname} of your ssh [hostname] command)
Good luck!
... and with your next try you will probably see

'The authenticity of host 'localhost (127.0.0.1)' can't be established ...'

Simply answer with 'yes'.
hi, i've tried that, but it still isn't working.
ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is a7:33:25:2e:da:a5:db:30:27:35:0f:73:92:c2:e3:58.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Ubuntu 8.04.1
Password: 
Password: 
Connection closed by UNKNOWN

Open in new window

This way we finally came back to our original problem...

Will return tomorrow at 9:00 a.m DFT (I'm in Germany here, you know ...)
Norbert
You need to specify the username to which you are connecting.  I think the issue with ssh -v localhost is that you use the root password while the ssh session expects anad's password.  If a user is not specified, the existing username is used in the ssh session request.

Run the following:
ssh -v root@localhost
Hi again,
arnold is completely right: You must check which user you are and which user you want to login as.
To possibly avoid the password question:
Please check the permissions of your ssh folders and files:
directory: .ssh must have drwx --- ---
files: authorized_keys and the private keys id_dsa, id_rsa etc must have -rw- --- ---
files: known_hosts and the public keys id_dsa.pub, id_rsa.pub must have -rw- r-- r--
All files must be owned by the user in whose home they are located.
would it matter if i just made the ./ssh world readable tempoarily?
thanks
Hi again
Do you mean the .ssh directory under your home?
Why should you make it world readable? And, yes, it would matter!
Permissions must be exactly as I wrote, unless you set  'strictmodes' in sshd_config to 'no' (not recommended!)

Norbert
would you be able to give me the chmod numbers?

thanks
chmod 700 .ssh (directory)
chmod 600 authorized_keys etc. (see above)
chmod 644 known_hosts etc. (see above)
hi, i'm getting the same error. i've attatched the ssh directory file permissions.
thanks
 ls -l 
total 36
-rw------- 1 anand anand 668 2008-09-30 22:11 id_dsa
-rw-r--r-- 1 anand anand 944 2008-10-01 17:32 id_dsa.keystore
-rw-r--r-- 1 anand anand 601 2008-09-30 22:11 id_dsa.pub
-rw------- 1 anand anand 526 2008-09-30 22:11 identity
-rw-r--r-- 1 anand anand 330 2008-09-30 22:11 identity.pub
-rw------- 1 anand anand 887 2008-09-30 22:11 id_rsa
-rw-r--r-- 1 anand anand 370 2008-10-01 17:32 id_rsa.keystore
-rw-r--r-- 1 anand anand 221 2008-09-30 22:11 id_rsa.pub
-rw-r--r-- 1 anand anand 442 2008-10-01 17:32 known_hosts
 
root@Anand:~/.ssh# ls -l /root/.ssh/authorized_keys
-rw------- 1 root root 330 2008-09-30 22:11 /root/.ssh/authorized_keys

Open in new window

try this while loged in as anand:
ssh -v -1 root@anand
post the results.
Also post the /etc/ssh/sshd_config.
Hi,
I will be out for a vacation till 10/10.
So long and Good Luck!
Norbert
hi, i can't use version 1:

anand@Anand:~$ ssh -v -1 root@anand
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to anand [127.0.1.1] port 22.
debug1: connect to address 127.0.1.1 port 22: Connection refused
ssh: connect to host anand port 22: Connection refused

with anand@Anand:~$ ssh -v -2 root@anand
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to anand [127.0.1.1] port 22.
debug1: connect to address 127.0.1.1 port 22: Connection refused
ssh: connect to host anand port 22: Connection refused

with anand@Anand:~$ ssh -v -2 root@localhost
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/anand/.ssh/id_rsa type 1
debug1: identity file /home/anand/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/anand/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 8.04.1
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Offering public key: /home/anand/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Offering public key: /home/anand/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
Password:

Port 22
 
# sample addresses only, change for your own needs!
ListenAddress 127.0.0.1
#ListenAddress 192.168.123.45
 
# restrict access and protocol level
AllowGroups ssh wheel
PermitRootLogin yes
Protocol 2
# HostKey locations for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
 
# specify encryption and MAC algorithms
Ciphers aes256-cbc,3des-cbc,blowfish-cbc
MACs hmac-sha1,hmac-ripemd160,hmac-md5
 
# select authentication preferences
PubkeyAuthentication yes
PasswordAuthentication yes
#HostbasedAuthentication no
HostbasedAuthentication yes
UsePAM yes
#UsePAM no
# disable ssh-agent forwarding
#ForwardAgent yes
 
## Defaults - uncomment to change
#
UsePrivilegeSeparation yes
SyslogFacility AUTH
LogLevel INFO
StrictModes no
#
AuthorizedKeysFile %h/.ssh/authorized_keys
#
PermitEmptyPasswords yes
#ChallengeResponseAuthentication yes
#
X11Forwarding no
#X11DisplayOffset 10
 
# information (banner and message of the day), and robust connections
Banner /etc/issue.net
PrintMotd yes
PrintLastLog yes
KeepAlive yes
 
# prevent guessers
LoginGraceTime 30
MaxStartups 5
 
# sftp support
Subsystem sftp /usr/lib/sftp-server

Open in new window

You are using your identity.pub in the authorized_keys.  Your SSHD configuration is requiring SSH v2 (Protocol 2)

Cat the id_rsa.pub and id_dsa.pub from the anand account into the authorized_keys of the root account and try again.
hi,
tried that, but it still isn't working.
just asks for my pw.
Are you sure the home dir for root is /home/root and not just /root?
how did you add the id*.pub into the authorized_keys ?
Did you cat id*.pub >> /home/root/.ssh/authorized_keys?
Try setting the authorized_keys to 644
chmod 644 /home/root/.ssh/authorized_keys.
post the following:
grep root /etc/passwd
the home dir is /root
root@Anand:/home/anand# chmod 644 /root/.ssh/authorized_keys
root@Anand:/home/anand# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash

Open in new window

how did you add the anand's public keys into the /root/.ssh/authorized_keys?
Did you can them into the file or did you copy and paste them using emacs, etc.?
i cat them with the >> (as shown above)
Try also:
cat id_*.pub >> /root/.ssh/authorized_keys2
And post the ssh -v root@anand

root@Anand:/home/anand/.ssh# cat id_*.pub >> /root/.ssh/authorized_keys2
root@Anand:/home/anand/.ssh# /etc/init.d/ssh restart
 * Restarting OpenBSD Secure Shell server sshd                           [ OK ] 
root@Anand:/home/anand/.ssh# ssh -v root@anand
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to anand [127.0.1.1] port 22.
debug1: connect to address 127.0.1.1 port 22: Connection refused
ssh: connect to host anand port 22: Connection refused

Open in new window

To test whether the public key login works, you have to ssh as anand and not as root.  The fact that you are sshing from the home directory of anand, does not mean that the ssh client will check these files.

The /etc/hosts table should reflect anand as localhost with ip 127.0.0.1 not sure why you have set a 127.0.1.1?

FYI: ssh does not need to be restarted unless alterations are made to the /etc/ssh/sshd_config files.  Files such as authorized_keys are read by the sshd daemon when a connection is attempted to the specified user.


Lets try this again.  login into your system as anand.
ssh -v root@127.0.0.1
Post the results.

anand@Anand:~$ ssh -v root@127.0.0.1
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/anand/.ssh/identity type 0
debug1: identity file /home/anand/.ssh/id_rsa type 1
debug1: identity file /home/anand/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is a7:33:25:2e:da:a5:db:30:27:35:0f:73:92:c2:e3:58.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 8.04.1
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Offering public key: /home/anand/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Offering public key: /home/anand/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: keyboard-interactive
Password: 

Open in new window

It seems that this is going further than before, but something is still missing.
The id_rsa and id_dsa have been offered, but i suspect that the access tot he authorized_keys is somehow missing.
Try this.  Comment out the ssh_config line:
#AuthorizedKeysFile %h/.ssh/authorized_keys
restart the sshd daemon and try again.

anand@Anand:~$ sudo su
[sudo] password for anand: 
root@Anand:/home/anand# /etc/init.d/ssh restart
 * Restarting OpenBSD Secure Shell server sshd                           [ OK ] 
root@Anand:/home/anand# ssh -v root@127.0.0.1
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] 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 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is a7:33:25:2e:da:a5:db:30:27:35:0f:73:92:c2:e3:58.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 8.04.1
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Offering public key: /root/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: keyboard-interactive
Password: 
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
Password: 
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
Password: 
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: password
root@127.0.0.1's password: 
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
Permission denied, please try again.
root@127.0.0.1's password: 
Received disconnect from 127.0.0.1: 2: Too many authentication failures for root
root@Anand:/home/anand# 

Open in new window

no luck yet :(
note that after you restart sshd, you need to exist from the elevated rights session to return to the anand account.
There is abolutely no reason to run su under sudo.
sudo bash or sudo /etc/init.d/ssh restart will do just as well.

Did you actually comment out the AuthorizedKeys line?  I am not sure what the %h/.ssh/authorized_keys lines translates.  Usually authorized_keys deals with SSH version 1 while authorized_keys2 dealt with ssh version 2 public keys.

Does your system have a NAT or external IP other then localhost?
Everything you've been told should have worked, it is not really clear why it is not working.

Try the following:
I presume you use graphical mode. open a console session sudo bash to elevate your session rights. run ps -ef | grep sshd
. run strace -f PID_OF_SSHD.
In the other session as anand run ssh -v root@127.0.0.1.
Look in the strace window to see whether an access attempt is being made to /root/.ssh/authorized_keys.

root@Anand:~# run ps -ef | grep sshd
bash: run: command not found
root@Anand:~# bash run ps -ef | grep sshd
bash: run: No such file or directory
root@Anand:~# . run strace -f PID_OF_SSHD.
bash: run: No such file or directory
root@Anand:~# . run strace -f PID_OF_SSHD.
bash: run: No such file or directory
 
anand@Anand:~$ ssh -v anand@127.0.0.1
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/anand/.ssh/identity type 0
debug1: identity file /home/anand/.ssh/id_rsa type 1
debug1: identity file /home/anand/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 none
debug1: kex: client->server 3des-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
debug1: Host '127.0.0.1' is known and matches the RSA host key.
debug1: Found key in /home/anand/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Ubuntu 8.04.1
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: publickey
debug1: Offering public key: /home/anand/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Offering public key: /home/anand/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive,hostbased
debug1: Next authentication method: keyboard-interactive
Password: 

Open in new window

sudo bash
ps -ef | grep sshd
strace -f

Did you comment out the AuthorizedKeys directive in the /etc/ssh/ssh_config file?  
Do you have another account on the system?  Copy anand's identity.pub and id_*.pub into that user's .ssh/authorized_keys file.
then as anand, ssh -v thatusername@127.0.0.1.

Public Key authentication works, but for some unknown reason it does not work for you.