Unable To Perform A "Passwordless" SSH Login To A Server


 
Thread Tools Search this Thread
Operating Systems HP-UX Unable To Perform A "Passwordless" SSH Login To A Server
# 1  
Old 04-19-2011
Unable To Perform A "Passwordless" SSH Login To A Server

Greetings!

I am trying to perform a passwordless SSH login from a HPUX 11.31 client to a HPUX 11.31 server. Whenever I do a "ssh -l root serverA" from the client, I am prompted for a password. Giving the password, I am able to successfully login. However I am trying to accomplish a "passwordless" authentication.

Yes, I have generated the keys on the client and exported them to the /root/.ssh/authorized_keys file on the server

On the server the permissions are set as follows:

Code:
# ls -al /root/.ssh
total 48
drwxr-xr-x 2 root sys 8192 Apr 19 16:58 .
drwxrwxrwx 5 root bin 96 Apr 16 14:55 ..
-rw-r--r-- 1 root sys 392 Apr 19 16:52 authorized_keys
-rw-r--r-- 1 root sys 884 Apr 19 17:25 known_hosts
#

From the client, I am able to successfully accomplish passwordless logins to other servers. It is only on serverA that I am prompted for a password.

When running ssh debug from the client, this is what I am getting:

Code:
# ssh -v root@serverA
OpenSSH_4.2p1-hpn, OpenSSL 0.9.7e 25 Oct 2004
HP-UX Secure Shell-A.04.20.009, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug1: Connecting to serverA [x.x.s.x] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/3
debug1: identity file /.ssh/id_rsa type 1
debug1: identity file /.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2p1+sftpfilecontrol-v1.3-hpn13v5
debug1: match: OpenSSH_5.2p1+sftpfilecontrol-v1.3-hpn13v5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.2p1-hpn
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
debug1: Host 'serverA' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:98
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
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:

Any ideas on what is going on that is preventing me from doing a passwordless SSH login?

Thanks!

robs

Last edited by pludi; 04-19-2011 at 08:24 PM..
# 2  
Old 04-20-2011
ssh -v is very informative, as is the web. Permissions on keys and their directories are critical, for instance. You can tell ssh which auth to limit itself to, so there is no prompt and it stops. Start with "ssh localhost pwd" and later move to trying the local ip, host name, remote ip, host name.
# 3  
Old 04-20-2011
Okay, I finally discovered what the problem was and fixed it. I would like to share the solution with the members of this thread because, even though the problem is now fixed, there was something in the solution
that I am not understanding (detailed down below).

Upon reading the system log (/var/adm/log/syslog/syslog.log), it reads as follows:

Apr 20 10:33:30 fyman00 sshd[25874]: Authentication refused: bad ownership or modes for directory /root

That, of course, got me in the ballpark...

I then looked at the permissions on /

# ls -al /
drwxrwxrwx 5 root bin 96 Apr 16 14:55 root

At that point, I knew the problem was going to be either "root bin" (improper owner) or "drwxrwxrwx" (incorrect permissions) or a
combination of both on the file /root

To determine which was the culprit, I corrected each one separately and then tested separately.

I then set the ownership to the correct setting: "root root". Retested and still could not achieve a successful passwordless (publickey) login. I then changed the mode to drwxr-xr-x I retested and then, you guessed it, I was able to successfully achieve a passwordless login. The final correction to /root reads as follows:

drwxr-xr-x 5 root root 96 Apr 16 14:55 root

Okay, here is the part that I do not understand: Why, after changing the mode from a LESS restrictive setting (drwxrwxrwx) to a MORE restrictive setting (drwxr-xr-x), why was I then allowed to finally authenticate correctly? This seems so counterintuitve... I'm quite certain that I am overlooking something rather basic...

Any ideas so I can finally put this one to bed? Thanks!

Rob S.


# 4  
Old 04-20-2011
Quote:
Originally Posted by Rob Sandifer
Why, after changing the mode from a LESS restrictive setting (drwxrwxrwx) to a MORE restrictive setting (drwxr-xr-x), why was I then allowed to finally authenticate correctly?
ssh refuses to operate on keys with incorrect permissions for security reasons. If /root is world-writable, there's no telling who actually put the keys in there!
# 5  
Old 04-20-2011
Quote:
Originally Posted by Corona688
ssh refuses to operate on keys with incorrect permissions for security reasons. If /root is world-writable, there's no telling who actually put the keys in there!
So, are you saying that the ssh application decides what permissions
are correct/incorrect?

Thanks!

Rob Sandifer
# 6  
Old 04-20-2011
No, sanity. No user should be able to change or steal another's keys, say to allow them to log in without password and no permissions.
# 7  
Old 04-20-2011
Quote:
Originally Posted by DGPickett
No, sanity. No user should be able to change or steal another's keys, say to allow them to log in without password and no permissions.
I understand the underlying meaning of what you are saying...that the
/root directory (which contains the public key) should always be secure.

What I am asking...is....what is the mechanism which drives the enforcement of the permissions? In other words, what I am asking is
what is actually causing the ssh public key authentication to actually
become disabled when directory level permissions on /root are loosened
rather than tightened.... Stated anothery way... is it the unix operating system or is it the ssh application itself which causes public key authentication to fail? Thanks.

Rob S.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Nim server "Unable to execute remote client commands"

Hello, What is its mean? Could you please help me? Best regards, root@nimserver:/> nimadm -j nimadmvg -c dev4 -s spot1 -l lpp_source1 -d "hdisk7" -Y Initializing the NIM master. Initializing NIM client dev4. 0042-006 c_rsh: (exec_nimsh_cmd) exec_cmd Error 0 poll: setup failure... (2 Replies)
Discussion started by: getrue
2 Replies

2. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

3. Shell Programming and Scripting

login to more than one pc (simultaneously) using "ssh"

Hi all, can any one have idea that " how to login to more than one PC (simultaneously) using "ssh" "? (1 Reply)
Discussion started by: kavi.mogu
1 Replies

4. AIX

ssh public key auth "Remote login for account is not allowed" ?

Hello, Using AIX 6.1 boxes. User user1 connects from box A to box B using ssh. When password authentication is used everything is fine. When I configure user1 to use public key authentication sftp client works fine(no password asked), but ssh client fails. This is sshd log: Accepted publickey... (3 Replies)
Discussion started by: vilius
3 Replies

5. UNIX for Advanced & Expert Users

How to allow particular user only to login as a root using "ssh" ?

Q1 I want to allow particular user only to login into root using ssh. I have set PermitRootLogin no for security purpose but I want to allow some of the users to login as a root using ssh how to do this? I have tried with Allowusers user1 user2 its working for only the user1 and... (3 Replies)
Discussion started by: ungalnanban
3 Replies

6. UNIX for Dummies Questions & Answers

how to install "source" command!/ broken "login.cl"!

Hello, I am new to this forums and this is my first "asking help" message! i have 2 problems: 1- for unknown reasons the "source" command is not avalable in my system (UBUNTU). i can't either see it in my bin directory! 2- again for unknown reasons the "login.cl" file in the home... (0 Replies)
Discussion started by: astrosona
0 Replies

7. Shell Programming and Scripting

script that can give login password for "ssh" without involving STDIN

Hi Folks, I am writing a shell script that can logon to remote machine automatically. But, I am facing one problem. I am using "ssh" command in script and while login into remote machine it asks for passowrd and it stops for STDIN input for password. I want my script to supply password... (2 Replies)
Discussion started by: gydave
2 Replies

8. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question