LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-04-2012, 03:21 AM   #1
Lucas Rey
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Rep: Reputation: Disabled
SSH KEY with root user doesn't work


Hello community,
I scratching my head with an issue on SSH KEY authorization.

I've a Red Hat 5.7 installation that should login via SSH into another machine (it's an OpenVMS OS). I already generated an SSH KEY and user "lucas" CAN login without password on destination machine! Then, if I try with user "root" it always ask me for the password!

The authorized_keys files between users are absolutely the same:
Quote:
-rw------- 1 lucas lucas 2803 Jul 6 2011 /home/lucas/.ssh/authorized_keys
-rw------- 1 root root 2803 Aug 4 09:35 /root/.ssh/authorized_keys
I've also another Red Hat test machine, that can login with "root" user, without problem and plus I can login with a Windows machine without password, both to the same destination server. So the problem isn't located on destination.

So, why I can login without password with "lucas" and ask me a password for "root" user? Is there any settings on Red Hat that prevent root user login with ssh key?

Please help, I'm driving crazy!
 
Old 08-04-2012, 05:00 AM   #2
Chirel
Member
 
Registered: Nov 2009
Posts: 55

Rep: Reputation: 19
Hi

Maybe it's just PermitRootLogin no in /etc/ssh/sshd_config ?
 
Old 08-04-2012, 05:09 AM   #3
Lucas Rey
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Chirel View Post
Maybe it's just PermitRootLogin no in /etc/ssh/sshd_config ?
No, PermitRootLogin is setup as yes:

Code:
# cat /etc/ssh/sshd_config | grep PermitRootLogin
PermitRootLogin yes
 
Old 08-04-2012, 05:54 AM   #4
Lucas Rey
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Wait, I discovered why it doesn't work!!!!

Connection to the "source" machine should be done DIRECTLY. If you connect to a machine, then SSH to "source" machine, and then try SSH on the "destination" machine it will ask for password. Instead, if you connect directly to the "source" machine and then SSH the "destination" machine it works!

Honestly I don't know if this behaviour is normal and why it happens! It will be much appreciated if someone can explain me!
 
Old 08-05-2012, 12:30 PM   #5
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
In normal ssh setup it does not matter how you logged in "source Machine" (directly/Indirectly)

Question 1. What command you are using to for ssh login (please paste both commands (for root and lucas user)?
2. Are you using the same ssh key pair for root and lucas or you have different SSH key pairs for each user?

PS: Although it is not concern here. Just let you know, it is a security issue to permit root logins on machines
 
Old 08-06-2012, 01:06 AM   #6
deadeyes
Member
 
Registered: Aug 2006
Posts: 609

Rep: Reputation: 79
Quote:
Originally Posted by Lucas Rey View Post
Wait, I discovered why it doesn't work!!!!

Connection to the "source" machine should be done DIRECTLY. If you connect to a machine, then SSH to "source" machine, and then try SSH on the "destination" machine it will ask for password. Instead, if you connect directly to the "source" machine and then SSH the "destination" machine it works!

Honestly I don't know if this behaviour is normal and why it happens! It will be much appreciated if someone can explain me!
To check this is might be good to use ssh -v when connecting. This will show all auth methods that are tried and if something went wrong with any of them.
 
1 members found this post helpful.
Old 08-06-2012, 08:42 AM   #7
Lucas Rey
LQ Newbie
 
Registered: Jul 2011
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by KinnowGrower View Post
In normal ssh setup it does not matter how you logged in "source Machine" (directly/Indirectly)

Question 1. What command you are using to for ssh login (please paste both commands (for root and lucas user)?
2. Are you using the same ssh key pair for root and lucas or you have different SSH key pairs for each user?
Response 1. Simple ssh connection i.e. ssh root@10.99.10.10 and ssh lucas@10.99.10.10
2. Yes same SSH keys for root and lucas users

BTW, I also knew that source machine doesn't matter in a "normal" SSH server config, but maybe there's something to prevent that for both users. Let me explain better witch is my environment. Since I cannot reach directly the first machine, I login first into another server (using the same SSH key) and then SSH to the final server. That operation doesn't work for both users.
Instead, if I use tunneling, to reach directly the 10.99.10.10 server, I'm able to login into the final server without password.


I cannot explain this behaviour, that's why I'm just curious if someone know.

Lucas

Last edited by Lucas Rey; 08-06-2012 at 08:45 AM.
 
Old 08-06-2012, 09:06 AM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
So the private keys on the machine in the middle maybe not be the same for both users. You could even use ssh-agent forwarding, then you don’t need any ssh-key on the machine in the middle at all.
 
  


Reply



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
startx doesn't work everytime as non root user kuroc Slackware 2 01-28-2012 09:05 AM
[SOLVED] ssh public key login doesn't work as root user confconf Fedora 6 04-06-2011 03:08 PM
root password doesn't work for ssh linuxuser00 Linux - Newbie 5 01-31-2007 11:05 AM
When I ssh to a server, the end key doesn't work (tcsh) TroelsSmit Linux - Newbie 0 10-07-2004 05:44 AM
Super User mode, my root password doesn't work? kko88 Linux - Newbie 8 05-20-2003 06:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:31 PM.

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