Wednesday, September 24, 2008

Root login fails with Permission denied on Unix

Problem Description
Using ssh whenever you try to login to another machine as a root user it failed with message Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive) like below.
Arju@debian:~$ ssh root@saturn
Password:
Password:
Password:
Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive).
Though I have provided the correct password but it fails. On server I can connect as other OS user rather than root and su as root user with password works. But from network it does not.

Cause of The Problem
In the machine to which you try to login within the script /etc/ssh/sshd_config parameter PermitRootLogin defines whether root user can ssh to the system or not.

Solution of The Problem
In order to see the contents of /etc/ssh/sshd_config you can issue,
$cat /etc/ssh/sshd_config

To see the settings of PermitRootLogin issue,
$ cat /etc/ssh/sshd_config |grep PermitRootLogin
PermitRootLogin no

As it is set to no so using ssh root connection is not accepted. In order to permit root login through network you have have to change this to yes from no after logging to the machine as a root user.

1)$su
password
#vi /etc/ssh/sshd_config
PermitRootLogin yes


2)Then restart the ssh daemon. On linux you can do it by,
#service sshd restart
On Solaris machine do it by,
# svcadm restart ssh

3)Then from another machine try to connect to the machine using root user.
Arju@debian:~$ ssh root@saturn
Password:
Last login: Fri Apr 25 11:15:34 2008
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
You have new mail.
#

And that's all.

No comments:

Post a Comment