Skip to main content

Ever thought about sudo in linux here is a complete meaning


Sudo In Linux — A Lot More Than An Elevated Permissions Tool

    

At times, it is necessary to perform tasks with root privileges, there are a few solutions for this, some more secure than the others. This article will outline those solutions with an emphasis on sudo and its broad ability that is virtually unknown to many system administrators.

When in need of running a process with elevated privileges, there are a three main solutions. Firstly, you can login as root, but this can only be done with the root password and still carries some security concerns. Secondly, you can use su to run a single command as root, still, this requires the root password. Lastly, there’s sudo, if improperly configured, it is a security nightmare, but if done properly, which is very easy, it can maintain a secure system while allowing flexibility in day to day operations.

The first step to understanding the power and flexibility of sudo is in understand the aliases.

User Alias – This is exactly as it sounds. These are aliases for users or groups of users. They aren’t as common, though, as system groups are typically used instead.

Command Alias – The command aliases are commands or groups of commands.

Host Alias – The host aliases are typically the more difficult concept to understand, especially since the sudo configuration only applies to the local system of the user. The sudo configuration is intended to be distributed to all systems for convenience. Being the relatively small text file that it is, it’s a very easily accomplished task, especially when using a system such at Puppet or Chef. The host aliases then refer to hosts or groups of hosts, the given rules are determined by the alias that the host is a part of.

Run As Alias – These are for specifying users or groups of users as target privileges for the execution of tasks. For example, giving privileges of the database administrative user.

Using these aliases, a very powerful, yet flexible, security model can be created. The best part is that this single file can be distributed across multiple machines and provide certain privileges to certain users on each. Furthermore, it is even more powerful because sudo is available on not only Linux, but several other UNIX and UNIX-like operating systems, meaning a well-written sudo configuration can be cross-platform as well.

All sudo configuration are made in the sudoers configuration file, typically homed in /etc/ on most Linux distributions. You can start editing the file using whichever editor you prefer, or you can issue the command:

visudo

From here we can start off by making a User Alias by using the User_Alias directive:

User_Alias DBADMINS = jane, john

Now, we’ll create a Command Alias to define the commands that the DBADMIN group is permitted to executed using the Cmnd_Alias directive:

Cmnd_alias DBCOMMANDS = /bin/db_backup, /bin/db_restore, /bin/db_start, /bin/db_stop

Next, we’ll create a Host Alias for a single server with the Host_Alias directive:

Host_Alias DBSERVERS = db1.example.com, db2.example.com

Note that the Host Alias can be specified using an IP as well.

And, lastly, we’ll create a Run As Alias using the Runas_Alias directive:

Runas_Alias DBPRIVS = db_admin_user

Finally, we have everything in place to create a rule, but first, we’ll need to review the sudoers rule syntax. The default sudoers file has a line in it pertaining to the root user. The root user already has complete access to the system, so the default sudo configuration does nothing to impede that, even out of the box. When looking though the default configuration you’ll find the below line.

root ALL=(ALL) ALL

The sudoers file syntax is a little bit esoteric, but we’ll clear that up. First, it’s obvious that this line defines a rule for the root user given that it starts with ‘root’, this is where we would put our User Alias or, as is the case for root, a single system user. Note that it can also be a system group as well, though it must be prepended with a ‘%’. The second piece of information is the ‘ALL’, this is the location or host identifier, we can, again, put a single host, or we can use one of our Host Aliases. Next, there is the equals sign, this delimits the rule itself and who it applies to. Now, we have ‘(ALL)’ which is a little funny looking because it’s in parenthesis. This item indicates who the command can be run as, either a single system user or group or our Run As Alias. Lastly, we have the command identifier where we can place a single command, a list of commands, or our Command Alias. Let’s construct a rule, now.

DBADMINS DBSERVER=(DBPRIVS) DBCOMMANDS

It’s as easy as that. By mixing these concepts and applying them thoughtfully, a secure model for system administration can be achieved in a straightforward way, across multiple systems, and even multiple platforms. One note of high importance, though, is that sudo will use the last match it finds in the sudoers configuration file.

There is much more functionality to sudo beyond what has been outlined here, including rules based on command parameters and the “!” (NOT) modifier. Although, the sudo philosophy is never to implicitly allow, but to explicitly allow and implicitly deny. That is, only give explicit permission to perform a task, but do not make an explicit rule denying a permission because it becomes easily circumvented.

Did we miss any big features of sudo? Let us know in the comments below.

Comments

Popular posts from this blog

Kali linux android simply amazing

How to Install and run Kali Linux on any Android Smartphone TUTORIAL FOR INSTALLING AND RUNNING KALI LINUX ON ANDROID SMARTPHONES AND TABLETS Kali Linux is one the best love operating system of white hat hackers, security researchers and pentesters. It offers advanced penetration testing tool and its ease of use means that it should be a part of every security professional’s toolbox. Penetration testing involves using a variety of tools and techniques to test the limits of security policies and procedures. Now a days more and more apps are available on Android operating system for smartphones and tablets so it becomes worthwhile to have  it on your smartphone as well. Kali Linux on Android smartphones and tablets allows researchers and pentesters to perform ” security checks” on things like cracking wep Wi-Fi passwords, finding vulnerabilities/bugs or cracking security on websites.  This opens the door to doing this from a mobile device such a...

What is DNS

D NS stands for Domain Name System is used to as the medium to translate domain names to their respective IP addresses when a client initiates a request query. DNS stores the database of all the domain names and their IP addresses which are registered on the network. Most of us are quite familiar with the term DNS or Domain Name System. DNS can be thought of as an attendance register for various websites present over the internet. In the case of DNS, it maintains the database of all the websites Domain Names and their IP (Internet Protocol) addresses that are operational all over the world. Historical Notes The origins of DNS date back to the time of the ARPANET  when there were only a few computers to get an entry in the database. A HOSTS.TXT file was maintained by Stanford Research Institute, which constituted the data of all the machines, and was copied by all the host machines to remain updated. Jon Postel from the Information Sciences Institute requested Pau...

How tor works

 Using the publicly available data, data visualization software firm Uncharted has prepared TorFlow — a map for visualizing how TOR’s data looks as it flows all across the world. It shows TOR network’s node and data movements based on the IP addresses of relays bouncing around the connections of users to avoid spying. TOR is the world’s most widely used tool for anonymity purposes . It has grown into a powerful network that’s spread all over the world. Surprisingly, the TOR project is transparent about the location of the TOR nodes and thousands of machines that power the network. This non-profit organization frequently published an updated list about the bandwidth and location of the computers and data centers spread all across the world. Using the same public data,  TorFlow  maps the TOR network’s nodes and data flow all around the world. This data movement is measured based on the IP addresses and bandwidth of the relay computers bouncing around the...