Como limitar o número de logins ativos por usuário?

7

Como posso limitar o número de logins ativos por usuário?

Eu já vi isso em vários servidores antes, e fiquei me perguntando como eu poderia configurar isso sozinho. Talvez nesses casos, isso foi feito limitando o número de logins SSH ativos por usuário? E eu acho que esse seria o caminho a percorrer. Como eu configuraria isso?

    
por Sildoreth 17.04.2015 / 20:03

3 respostas

5

/etc/security/limits.conf , pelo menos no Debian. O caminho pode variar um pouco por distro. Há um exemplo no arquivo para limitar todos os membros do grupo student a 4 logins (comentados):

#<domain>      <type>   <item>          <value>
@student       -        maxlogins       4

Você pode fazer * em vez de um grupo, mas não bater nos usuários que não deseja limitar (por exemplo, um membro da equipe)

    
por 17.04.2015 / 20:13
4

De acordo com o homem de limits.conf , você pode definir restrições em /etc/security/limits.conf :

maxsyslogins 
maximum number of all logins on system 

Então você pode definir (2 logins):

* hard maxsyslogins 2

Em outro post é dito não usar /etc/security/limits.conf . Não consegui encontrar nada relacionado a isso, exceto que o valor que é definido no arquivo /etc/security/limits.d/*.conf substituirá o mesmo valor em /etc/security/limits.conf .

De man pag de pam_limits :

By default limits are taken from the /etc/security/limits.conf config file. Then individual *.conf files from the /etc/security/limits.d/ directory are read. The files are parsed one after another in the order of "C" locale. The effect of the individual files is the same as if all the files were concatenated together in the order of parsing. If a config file is explicitly specified with a module option then the files in the above directory are not parsed.

    
por 17.04.2015 / 20:13
0

Em sistemas GNU / Linux modernos, pam_limits pode limitar o número de sessões por usuário.

Para limitar o número de sessões por usuário, você pode adicionar entradas a um arquivo em /etc/limits.d/ (digamos, /etc/limits.d/maxlogins.conf )

# Some of the lines in this sample might conflict and overwrite each other
# The whole range is included to illustrate the possibilities
#limit users in the users group to two logins each
@users       -       maxlogins     2
#limit all users to three logins each
*            -       maxlogins     3
#limit all users except root to 20 simultaneous logins in total
*            -       maxsyslogins     20
#limit in the users group to 5 logins in total
%users       -       maxlogins     2
#limit all users with a GID >= 1000 to two logins each
1000:        -       maxlogins     2
#limit user johndoe to one login
johndoe      -       maxlogins     2

Outros sistemas operacionais e sistemas semelhantes ao Unix sem o módulo pam_limits seriam diferentes.

    
por 16.11.2017 / 14:49

Tags