Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

in openssh, you can restrict root login (PermitRootLogin no) but can it have an exception?

share|improve this question
    
But that would mean that root login was permitted ... why not login as a user and then su / sudo? –  pjc50 May 29 '12 at 13:13
    
I'm sorry, but what exception? Either you permit root login or you don't. –  Dennis May 29 '12 at 13:13

1 Answer 1

Given that logging in as root is not a good idea, have a look at sshd manpage:

PermitRootLogin

Specifies whether root can log in using ssh(1). The argument must be ``yes'', ``without-password'', ``forced-commands-only'' or ``no''. The default is ``yes''.

If this option is set to ``without-password'' password authenti- cation is disabled for root.

If this option is set to ``forced-commands-only'' root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root.

If this option is set to ``no'' root is not allowed to log in.

So you could use PermitRootLogin without-password for allowing private/public key authentication while disallowing password authentication; or maybe PermitRootLogin forced-commands-only to let you login as root but without interactive access.

The latter case requires you to edit authorized_keys file, to specify which command is enabled for the logging is user, like this:

command="rdiff-backup --server" ssh-rsa AAAAB3NzaC1y... (rest of key)

or even better, allow forced-commands-only root login only from specific ip address:

from="10.1.1.1",command="/home/user/command/to/execute" ssh-rsa AAAAB3NzaC1y... (rest of key)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.