0

A simple question, I've been looking everywhere and I couldn' find the answer : How can I limit my root account in Debian ? I need that the root have access only to one connection at a time in the terminal.

Any advice will be appreciated.

Jakuje
  • 9,715
  • 2
  • 42
  • 45
  • 2
    This has an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) feel about it. What problem are you actually trying to solve, here? – MadHatter Nov 17 '15 at 09:14
  • Even if you can configure this, you are aware that the root user has the rights to remove these restrictions, right? – Gerald Schneider Nov 17 '15 at 09:15

2 Answers2

1

Allowed user on ssh

Edit /etc/ssh/sshd_config

AllowUsers root@{serverIP}

Limit ssh connexion to 1

Edit /etc/security/limits.conf

root    hard    maxlogins    1
Froggiz
  • 3,043
  • 1
  • 19
  • 30
0

If you want to have only one root session in one time, you will have to implement some kind of reject script to be run after authentication. For this, the ForceCommand option in sshd_config is really useful.

The script can looks basically somehow like this:

ForceCommand users | grep root || $SSH_ORIGINAL_COMMAND

If ssh is not the concern, then you can put something like this into your .bashrc or .profile:

users | grep root && exit
Jakuje
  • 9,715
  • 2
  • 42
  • 45