Ganando Privilegios
Los administradores de sistema, y en algunos casos los usuarios, necesitan
llevar a cabo ciertas tares con acceso administrativo. El acceso al sistema
como usuario root`es potencialmente peligroso y puede llevar a daños muy
extendidos en el sistema y los datos. Este capítulo cubre diversas maneras
de obtener privilegios administrativos usando programas setuid como
su y sudo. Estos programas permiten a usuarios
específicos llevar a cabo tareas que normalmente solo están disponibles para
el usuario `root
a la vez que mantienen el mas alto nivel de control y de
seguridad del sistema.
Vea en Red Hat Enterprise Linux 7 Guía de Seguridad mas información sobre los controles administrativos, los peligros potenciales y la manera de evitar la perdida de datos como resultado de un uso inapropiado del acceso privilegiado.
El Comando su
Cuando un usuario ejecuta el comando su, se le pide la contraseña
de root
y, después de la autenticación, se le da un acceso root
.
Una vez se ha accedido usando el comando su, el usuario es
usuario root
y tiene acceso absoluto de administrador al sistema. Advierta
que este acceso está todavía sujeto a las restricciones impuestas por
SELinux, si está habilitado. Además, una vez que un usuario ha llegado a ser
root
, es posible para el usar el comando su para cambiar a
cualquier otro usuario del sistema sin que le sea pedida la contraseña.
Puesto que este programa es tan poderoso, los administradores de una organización deben limitar a quienes tienen acceso al comando.
Una de las maneras mas sencillas de hacer esto es añadir los usuarios al
grupo especial de administradores llamado wheel. Para hacer esto teclee el
siguiente comando como root
:
~]# usermod -a -G wheel username
En el anterior comando, reemplace username con el nombre del usuario que
desea añadir al grupo wheel
.
También puede usar la herramienta de ajustes Users para modificar la membresía de grupo tal como sigue. Advierta que necesita privilegios de administrador para llevar a cabo este procedimiento.
-
Presione la tecla Super para entrar en la Visión General de Actividades, teclee Usuarios y pulse la tecla Enter. Aparece la herramienta de ajustes de Usuarios. La tecla Super aparece de diversas formas, dependiendo del teclado y otro hardware pero con frecuencia es la tecla Windows o Command y normalmente está a la izquierda de la Barra Espaciadora.
-
Para poder hacer cambios pulse el botón Desbloquear e introduzca una contraseña válida de administrador.
-
Click a user icon in the left column to display the user’s properties in the right-hand pane.
-
Change the Account Type from
Standard
toAdministrator
. This will add the user to thewheel
group.
See Managing_Users_and_Groups.adoc#s1-users-configui for more information about the Users tool.
After you add the desired users to the wheel
group, it is advisable to
only allow these specific users to use the su command. To do
this, edit the PAM configuration file for su,
/etc/pam.d/su
. Open this file in a text editor and uncomment the following
line by removing the #
character:
#auth required pam_wheel.so use_uid
This change means that only members of the administrative group wheel
can
switch to another user using the su command.
Aviso
The |
The sudo Command
The sudo command offers another approach to giving users
administrative access. When trusted users precede an administrative command
with sudo, they are prompted for their own password. Then, when
they have been authenticated and assuming that the command is permitted, the
administrative command is executed as if they were the root
user.
The basic format of the sudo command is as follows:
sudo command
In the above example, command would be replaced by a command normally
reserved for the root
user, such as mount.
The sudo command allows for a high degree of flexibility. For
instance, only users listed in the /etc/sudoers
configuration file are
allowed to use the sudo command and the command is executed in
the user’s shell, not a root
shell. This means the root
shell can be
completely disabled as shown in the
Red Hat
Enterprise Linux 7 Security Guide.
Each successful authentication using the sudo command is logged
to the file /var/log/messages
and the command issued along with the
issuer’s user name is logged to the file /var/log/secure
. If additional
logging is required, use the pam_tty_audit
module to enable TTY auditing
for specified users by adding the following line to your
/etc/pam.d/system-auth
file:
session required pam_tty_audit.so disable=pattern enable=pattern
where pattern represents a comma-separated listing of users with an
optional use of globs. For example, the following configuration will enable
TTY auditing for the root
user and disable it for all other users:
session required pam_tty_audit.so disable=* enable=root
Another advantage of the sudo command is that an administrator can allow different users access to specific commands based on their needs.
Administrators wanting to edit the sudo configuration file,
/etc/sudoers
, should use the visudo command.
To give someone full administrative privileges, type visudo and add a line similar to the following in the user privilege specification section:
juan ALL=(ALL) ALL
This example states that the user, juan
, can use sudo from any
host and execute any command.
The example below illustrates the granularity possible when configuring sudo:
%users localhost=/sbin/shutdown -h now
This example states that any member of the users
system group can issue
the command /sbin/shutdown -h now as long as it is issued from
the console.
The man page for sudoers
has a detailed listing of options for this file.
Important
There are several potential risks to keep in mind when using the
sudo command. You can avoid them by editing the
|
Recursos Adicionales
While programs allowing users to gain administrative privileges are a potential security risk, security itself is beyond the scope of this particular book. You should therefore refer to the resources listed below for more information regarding security and privileged access.
-
su
(1) — The manual page for su provides information regarding the options available with this command. -
sudo
(8) — The manual page for sudo includes a detailed description of this command and lists options available for customizing its behavior. -
pam
(8) — The manual page describing the use of Pluggable Authentication Modules (PAM) for Linux.
-
The Red Hat Enterprise Linux 7 Security Guide provides a more in-depth look at potential security issues pertaining to setuid programs as well as techniques used to alleviate these risks.
-
Managing_Users_and_Groups.adoc#ch-Managing_Users_and_Groups documents how to manage system users and groups in the graphical user interface and on the command line.