3

An exceptionally newbie question, sorry. I'm running a Debian machine as root:

$whoami
root

If I carefully change the password (over VNC), it seems to work:

debian:/# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

If I then try to ssh in, carefully typing in the password I just set, I get 'Permission denied':

:~ ap257$ ssh [email protected]
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied, please try again.

What could be going wrong?

----UPDATE--------

Solved, see my answer below (I can't accept it until tomorrow). Your thoughts on why on earth this worked would be very much appreciated!

5 Answers 5

4

Most likely the 'root' account is not permitted to log in via SSH.

Locate the config file, usually stored at

  /etc/ssh/sshd_config

Look for the line that says

 PermitRootLogin No

Change it to say

PermitRootLogin Yes

Make sure you restart the SSH daemon after making the change!

service sshd restart
8
  • 6
    dont enable root to ssh, make other users and give them sudo permissions
    – JamesRyan
    Jul 7, 2010 at 14:29
  • 1
    Or only permit key authentication
    – Maxfer
    Jul 7, 2010 at 14:31
  • 1
    If you are security-conscious, yes best practice is to give a regular user sudo capabilities by adding the user to the '/etc/sudoers' file.
    – mistiry
    Jul 7, 2010 at 14:32
  • Hm. I don't have this file and 'find' doesn't produce anything by that name either. Do I need to install ssh?
    – AP257
    Jul 7, 2010 at 14:49
  • OK, done apt-get install ssh: opened sshd_config and edited: restarted ssh (using /etc/init.d/ssh restart). Still no joy, still getting 'Permission denied'. :(
    – AP257
    Jul 7, 2010 at 14:54
4

Create a new user with useradd, then set the passwd with passwd [user]. i.e.

useradd johndoe
passwd johndoe

Then SSH using johndoe, and then use the switch user command su - to get to root.


Note the dash. This is very important to set your environment like you probably want. Without the dash I believe you would end up at a prompt under root, but would have to use absolute paths. Normally the syntax is su [user], but the default is root if it is omitted.

Ideally you would also use Sudo, but the above is more proper than simply SSHing in under root. It is likely as mentioned in the other answers your sshd configuration disallows root login.

The reason root login is disallowed is because remote root access can be higher risk than needed security wise. Using the above method you would have to crack two layers to get root access, as opposed to just "knocking down the front door."

You can also look in /var/log/secure to see why your password was rejected.

6
  • Thanks for the explanation. But that doesn't help - still get 'Permission denied', even logging as my new user....
    – AP257
    Jul 7, 2010 at 14:50
  • What does your /var/log/secure log say? (At the bottom) Or does this file not exist either? Try "tail /var/log/secure" Jul 7, 2010 at 14:54
  • No such file. It's a brand new Debian install, maybe that's why?
    – AP257
    Jul 7, 2010 at 14:59
  • hmmm, it should (provided usual vanilla SSH) have been created when you first tried to login, especially if you are getting permission denied. Edit: I looked it up and debian actually doesn't use a logger by default - doh me. It's a long shot, but does lastb show your login attempts on the server your trying to login to? (last would show your successful attempts) Jul 7, 2010 at 15:04
  • 2
    By default, this stuff should be logged to /var/log/auth.log Jul 7, 2010 at 15:15
1

I once had this problem. It was because root login was disallowed by the sshd configuration.

Ensure that PermitRootLogin is set to yes at /etc/ssh/sshd_config config file, although I'm not exactly sure if this is where it's found under debian

1

maybe that you got different keyboard mappings ?

try typing the password where you can see it.

1
  • good idea - but on inspection the passwords are the same...
    – AP257
    Jul 8, 2010 at 10:00
0

Thanks to everyone for all the suggestions. I eventually solved by chance, by typing

$ passwd root

and doing everything the same as before. I have no idea why this worked when

$ whoami
root
$ passwd

didn't. Can anyone explain?

You must log in to answer this question.