Archive for September, 2009

SBDavid

The visudo command

The visudo command.

The sudo command also provides a comprehensive audit trail. Each successful authentication 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.

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:

visudo

and then

admin ALL=(ALL) ALL

This example states that the user, admin, 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 user can issue the command /sbin/shutdown -h now as long as it is issued from the console.

The sudoers file should always be edited by the visudo command which locks the file and does grammatical checking. It is imperative that sudoers be free of syntax errors since sudo will not run with a syntactically incorrect sudoers file.

SBDavid

The sudo Command

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, once authenticated and assuming that the command is permitted, the administrative command is executed as if by 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.

Example from /etc/sudoers

# User privilege specification
root ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL

# Members of the admin group may gain root privileges

%admin ALL=(ALL) ALL
%eeeuser ALL=NOPASSWD: /etc/acpi/eeepc/eeepc-actions.sh, /etc/acpi/eeepc/eeepc-lvds-toggle.sh
SBDavid

Disabling Root Using PAM

Disabling Root Using PAM

PAM, through the /lib/security/pam_listfile.so module, allows great flexibility in denying specific accounts.

This allows the administrator to point the module at a list of users who are not allowed to log in.

Below is an example of how the module is used for the vsftpd FTP server in the /etc/pam.d/vsftpd PAM configuration file (the \ character at the end of the first line in the following example is not necessary if the directive is on one line):

auth required /lib/security/pam_listfile.so item=user \ sense=deny file=/etc/vsftpd.ftpus

This tells PAM to consult the file /etc/vsftpd.ftpusers and deny access to the service for any user listed. The administrator is free to change the name of this file, and can keep separate lists for each service or use one central list to deny access to multiple services.

SBDavid

Limiting Root Access

Limiting Root Access

Rather than completely deny access to the root user, the administrator may want to allow ac-cess only via setuid programs, such as su or sudo.

Upon typing the su command, the user is prompted for the root password and, after authentica-tion, is given a root shell prompt.

:~$ su
Password:
root@laptop:#

Once logged in via the su command, the user is the root user and has absolute administrative access to the system. In addition, once a user has become root, it is possible for them to use the su command to change to any other user on the system without being prompted for a password.

Because this program is so powerful, administrators within an organization may wish to limit who has access to the command.

One of the simplest ways to do this is to add users to the special administrative group called wheel. To do this, type the following command as root:

usermod -G wheel username

In the previous command, replace with the username you want to add to the wheel group.

You can also try using the command prompt for this, type the command system-config-users at a shell prompt.

Select the Users tab, select the user from the user list, and click Properties from the button menu (or choose File => Properties from the pull-down menu).

Then select the Groups tab and click on the wheel group.

Next, open the PAM configuration file for su (/etc/pam.d/su) in a text editor and remove the comment # from the following line:

auth required /lib/security/$ISA/pam_wheel.so use_uid

Doing this permits only members of the administrative group wheel to use the program.

Methods of Disabling the Root Account.

Changing the root shell.

To prevent users from logging in directly as root, the system administrator can set the root ac-count’s shell to /sbin/nologin in the /etc/passwd file.

Edit the /etc/passwd file and change the shell from /bin/bash to /sbin/nologin.

The following programs are prevented from ac-cessing the root account:

· login
· gdm
· kdm
· xdm
· su
· ssh
· scp
· sftp

Programs that do not re-quire a shell, such as FTP clients, mail clients, and many setuid programs. The following programs are not prevented from accessing the root ac-count:

· sudo
· FTP clients
· Email clients

Disabling root ac-cess via any con-sole device (tty).

An empty /etc/securetty file prevents root login on any devices attached to the computer.

echo > /etc/securetty

Disabling root SSH Login.

Edit the /etc/ssh/sshd_config file, and set the PermitRootLo-gin parameter to no.

# PermitRootLogin yes

to

#PermitRootLogin no

Use PAM to limit root access to services.

Edit the file for the target service in the /etc/pam.d/ directory. Make sure the pam_listfile.so is re-quired for authentication.

« Prev - Next »