LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   my sshd accepts root login without password (http://www.linuxquestions.org/questions/linux-newbie-8/my-sshd-accepts-root-login-without-password-892320/)

oxident 07-18-2011 09:43 AM

my sshd accepts root login without password
 
Hello.

I'm trying to figure out why my industrial appliance (x86, running kernel 2.6.21.7 and OpenSSH_4.3p2 / OpenSSL 0.9.7m) accepts ssh connections without asking for a password (even for root)!

When I log on to the local console as root I have to enter a password but strangely this prompt won't appear using a ssh connection (although I'm not using any client certificates).

Of course that not acceptable but I just can't find the related configuration entry to disable this "password-less" authentification.

Is this related to the sshd or has it something to do with the PAM module?

Thanks for any help!

- Update ->
While looking at /var/log/secure, I've found the following lines:
Jul 18 16:55:07 localhost sshd[5712]: Accepted none for root from XXX port 6393 ssh2
Jul 18 16:55:07 localhost sshd[5712]: Deprecated pam_stack module called from service "sshd"
Jul 18 16:55:07 localhost sshd[5712]: Deprecated pam_stack module called from service "sshd"
Jul 18 16:55:07 localhost sshd[5712]: pam_unix(sshd:session): session opened for user root by (uid=0)

MCD555 07-18-2011 10:09 AM

Quote:

Originally Posted by oxident (Post 4418152)
Hello.

I'm trying to figure out why my industrial appliance (x86, running kernel 2.6.21.7 and OpenSSH_4.3p2 / OpenSSL 0.9.7m) accepts ssh connections without asking for a password (even for root)!

When I log on to the local console as root I have to enter a password but strangely this prompt won't appear using a ssh connection (although I'm not using any client certificates).

Of course that not acceptable but I just can't find the related configuration entry to disable this "password-less" authentification.

Is this related to the sshd or has it something to do with the PAM module?

Thanks for any help!

- Update ->
While looking at /var/log/secure, I've found the following lines:
Jul 18 16:55:07 localhost sshd[5712]: Accepted none for root from XXX port 6393 ssh2
Jul 18 16:55:07 localhost sshd[5712]: Deprecated pam_stack module called from service "sshd"
Jul 18 16:55:07 localhost sshd[5712]: Deprecated pam_stack module called from service "sshd"
Jul 18 16:55:07 localhost sshd[5712]: pam_unix(sshd:session): session opened for user root by (uid=0)


Try posting the /etc/ssh/sshd_config to check the parameters.
Or just verify the your /etc/ssh/sshd_config contains the follow instruction:

PermitRootLogin no

that is always a good minimum security policy to follow....

Hope this helps!

oxident 07-19-2011 05:36 AM

Well, that's my sshd_config:
Code:


#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile        .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PermitEmptyPasswords yes
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem        sftp        /usr/libexec/openssh/sftp-server

But I really want to allow root login using ssh. My only problem is that I need SSHd to ask for the account's password.

vinaytp 07-19-2011 08:02 AM

Hi,

Please read some literature on Password less SSH login in google( which is normally used in automation, with scripts without any user intervention). It is advisable to disable direct ssh login for root for security reasons.

Here is a link to help you on password less login, which someone might have configured on your system.
Password Less Login

oxident 07-19-2011 08:39 AM

Yes, I have already read a lot regarding password-less login (and I also use the process for scripting issues on other machines) but every site, I've visited deals with client-side certificates. As far as I've understood your link, this involves generating a certificate which is used to authentificate with the server.

But in my case, there's definitely no kind of certificate installed. I can even login from my mobile phone as root without entering any password.

I would have no problem with disabling root access via ssh, but my sshd won't even prompt for a password when using different accounts!

reverend_hh 07-19-2011 11:02 AM

Try changing PermitEmptyPasswords to no instead of yes then restart the service.

Oh and as a side note change PermitRootLogin to no. Once you login as a regular user, just su to root.

MCD555 07-19-2011 11:14 AM

Quote:

Originally Posted by oxident (Post 4418984)
Yes, I have already read a lot regarding password-less login (and I also use the process for scripting issues on other machines) but every site, I've visited deals with client-side certificates. As far as I've understood your link, this involves generating a certificate which is used to authentificate with the server.

But in my case, there's definitely no kind of certificate installed. I can even login from my mobile phone as root without entering any password.

I would have no problem with disabling root access via ssh, but my sshd won't even prompt for a password when using different accounts!

One or more line(s) to change:

PermitEmptyPasswords yes => change this to no

This should solve your doubts about root without password login: this is an HUGE security hole, I think you should change this as soon as possible!


Also you should:

1.) as root generate a DSA and a RSA server key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_dsa_key
2.) enable the following config lines:
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
3.) enable strictModes
StrictModes yes
4.) enable the following (key authentication):
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

For further infos a good link would be this:
http://www.cyberciti.biz/tips/linux-...practices.html

Last, generate a key on your client machine and use the key authentication as much as you can!

Hope this helps!

oxident 07-21-2011 03:09 AM

Quote:

Originally Posted by MCD555 (Post 4419151)
One or more line(s) to change:

PermitEmptyPasswords yes => change this to no

This should solve your doubts about root without password login: this is an HUGE security hole, I think you should change this as soon as possible!

Thanks for this hint. If I change this setting I'm not able to log in using keyboard/interactive authentification anymore ("login permitted") :scratch:
I think, the problem is that there's is no user with an empty password (although sshd won't ask for a password)!

Before implementing the certificate security I would really like to "restore" the behaviour to what I know from other Linux installation (which means: root login is disabled and other users can login in with their passwords)...

MCD555 07-21-2011 06:44 AM

Quote:

Originally Posted by oxident (Post 4420947)
Thanks for this hint. If I change this setting I'm not able to log in using keyboard/interactive authentification anymore ("login permitted") :scratch:
I think, the problem is that there's is no user with an empty password (although sshd won't ask for a password)!

Before implementing the certificate security I would really like to "restore" the behaviour to what I know from other Linux installation (which means: root login is disabled and other users can login in with their passwords)...

Weel, to permit password authentication just set the parameter:

PasswordAuthentication yes

On that linux box does exist the specific user with a valid password?

Try posting the output from a client point of view (using ssh -vvv user@IP or similar).

Hope this helps!


All times are GMT -5. The time now is 08:34 AM.