Enable root access via ssh "access denied"

Support for security such as Firewalls and securing linux
ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 05:17:24

Just installed minimal centos 6.4 image

want to give root access via ssh.

I have set PermitRootLogin = yes in sshd_config also added AllowUsers = root xxxx

Still cannot ssh as a root. Normal user can ssh. also if I try su (once logged in as a normal user via ssh), I get the message "su: incorrect password"

Do I need to do anything else to use su or allow root access via ssh?

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: Enable root access via ssh "access denied"

Post by avij » 2013/11/09 06:16:24

By default, sshd allows root logins without any changes to sshd_config. I wonder what else you've changed in your config to disable root logins.

Please note that "PermitRootLogin yes" is generally not recommended.

ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Re: Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 09:43:51

Buy default it DOES NOT allow root ssh access. I am quite sure about it.

Nothing else has been changed.
i only added allowusers based on some recommendation on the web.

User avatar
TrevorH
Site Admin
Posts: 33037
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Enable root access via ssh "access denied"

Post by TrevorH » 2013/11/09 10:09:51

You can be quite sure about it but you'd still be wrong. The settings in /etc/ssh/sshd_config on CentOS do allow root access by default. Please post the contents of your /etc/ssh/sshd_config file inside code tags to preserve the formatting.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Re: Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 10:10:30

The reason i started looking at solutions/options as it did not allow ssh access for root at the first place immediately after installation (without any changes ot any config).

On another note, su works when logged into the console as another user. But does not work when ssh as another user. I assume, the key problem here is root does not have ssh access somehow.

ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Re: Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 10:18:28

May be i am wrong.

Here is the content of ssd_config
Last edited by ashabc on 2013/11/09 10:32:13, edited 1 time in total.

ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Re: Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 10:24:04

Code: Select all

#	$OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# 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 1024

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

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
AllowUsers xxxxx root
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile	.ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody

# 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
PasswordAuthentication yes

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

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

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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 and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to '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 LANGUAGE
AcceptEnv XMODIFIERS

#AllowAgentForwarding yes
#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
#ChrootDirectory none

# no default banner path
#Banner none

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

# Example of overriding settings on a per-user basis
#Match User anoncvs
#	X11Forwarding no
#	AllowTcpForwarding no
#	ForceCommand cvs server

User avatar
TrevorH
Site Admin
Posts: 33037
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Enable root access via ssh "access denied"

Post by TrevorH » 2013/11/09 10:36:12

Hmmm. The fact that su does not work from an ssh session sounds very odd to me and the most likely candidate I can think of for this would be that something is mislabeled from an selinux POV. Can you run `setenforce 0` and then try again and see if it works? This puts selinux into permissive mode so it goes through all the motions of protecting you, including writing logs about what would be denied, but then allows the access anyway. If that works, the run the command `aureport -a` and take the last few lines output, look at the right hand end of each line for a number and plug that number into `ausearch -a nnnn` (where nnnn is the number).

Post the output from the ausearch commands here for the last 2 or 3 lines in aureport -a.

BTW, the default /etc/ssh/sshd_config has only the following lines uncommented in it

Code: Select all

# grep -v "^#" /etc/ssh/sshd_config | grep -v "^$"
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
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 LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
Subsystem       sftp    /usr/libexec/openssh/sftp-server
The remaining comments in the file show what the defaults are for those parameters when they are not specified and "#PermitRootLogin yes" is in there.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

ashabc
Posts: 15
Joined: 2013/11/09 05:00:08

Re: Enable root access via ssh "access denied"

Post by ashabc » 2013/11/09 10:46:27

I have run the command setenforce 0

Still root ssh does not work. Same message "access denied".

User avatar
TrevorH
Site Admin
Posts: 33037
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Enable root access via ssh "access denied"

Post by TrevorH » 2013/11/09 11:00:33

OK, well at least that rules out selinux as the cause of the problem.

Is there anything logged in /var/log/secure or /var/log/messages when you attempt to su to root from the ssh session?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply