LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How does the root user work? (https://www.linuxquestions.org/questions/linux-newbie-8/how-does-the-root-user-work-4175460871/)

Altiris 05-06-2013 05:50 AM

How does the root user work?
 
I understand it has privileges to everything and should only be used when really needed and then logged out. However I have a couple of questions,

1. Is the root user password hashed/encrypted?
2. If the root account is disabled (like on linux mint) could a "virus" enable it?
3. If a "virus" could enable the root account, couldn't it then also set up the root password since it was never set before?

nigelc 05-06-2013 07:13 AM

1 = yes
2 =yes maybe
3 = yes

tronayne 05-06-2013 07:18 AM

Yes, the root password (and all user account passwords) is/are encrypted.

If you look at /etc/passwd, it will look, in part, something like this:
Code:

root:x:0:0::/root:/bin/ksh
bin:x:1:1:bin:/bin:/bin/false
daemon:x:2:2:daemon:/sbin:/bin/false
adm:x:3:4:adm:/var/log:/bin/false
lp:x:4:7:lp:/var/spool/lpd:/bin/false
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/:/bin/false

Those are system account, starting with root (there are more, including user accounts).

/etc/passwd is made of of fields separated by colons; the last field contains the shell program started at log in. On my systems, I define that as KornShell rather than BASH, so it's /bin/ksh instead of /bin/bash.

The other "optional user command interpreter" (that's the last one) are specified /bin/false so no one can log in to any of those user accounts (they're not really user accounts, they're for system administration). You should not fool around with any of them for any reason, by the way.

Now, the second field, "optional encrypted password," contains an "x" indicating that the actual encrypted password is stored in /etc/shadow. That looks something like this (note: you must be root to see the shadow file):
Code:

root:$1$a7IEQ/cm$N33kwrt.F6iuXHEKq5/NS/:15106:0:::::
bin:*:9797:0:::::
daemon:*:9797:0:::::
adm:*:9797:0:::::
lp:*:9797:0:::::
sync:*:9797:0:::::
shutdown:*:9797:0:::::
halt:*:9797:0:::::
mail:*:9797:0:::::

There is one line in /etc/shadow corresponding to each line in /etc/passwd. If the second field in /etc/shadow is an asterisk, there is no password (and no log in is possible).

Anybody can read /etc/passwd (you can look at); nobody, except root, can read /etc/shadow. The permissions on those two files should never be fiddled around with for any reason.

Now, about "viruses."

Essentially, you want to use strong passwords:
Quote:

Compromises in password security normally result from careless password selection
or handling. For this reason, you should not select a password which appears in a
dictionary or which must be written down. The password should also not be a proper
name, your license number, birth date, or street address. Any of these may be used
as guesses to violate system security.

You can find advices on how to choose a strong password on
http://en.wikipedia.org/wiki/Password_strength
The above from the passwd page.

For example, "good" passwords include upper- and lower case letters, numeric characters, punctuation characters and are at least eight characters in length (longer is even better) -- read the Wikipedia article.

Viruses? Not really applicable (this ain't Windows). You protect yourself with good passwords.

You should take some time and read the manual pages for passwd and shadow and, perhaps, the "See Also" references at the bottom of each of those manual pages for a better understanding of how all this works:
Code:

man passwd
man 5 shadow

Hope this helps some.

SLW210 05-06-2013 07:38 AM

From the Wikipedia link posted above..

Quote:

Using strong passwords lowers overall risk of a security breach, but strong passwords do not replace the need for other effective security controls. The effectiveness of a password of a given strength is strongly determined by the design and implementation of the authentication system software, particularly how frequently password guesses can be tested by an attacker and how securely information on user passwords is stored and transmitted. Risks are also posed by several means of breaching computer security which are unrelated to password strength. Such means include wiretapping, phishing, keystroke logging, social engineering, dumpster diving, side-channel attacks, and software vulnerabilities.

Altiris 05-06-2013 02:05 PM

Alright but so shouldn't all distributions when installing allow someone to set a root password and then after installation disable the account? It's better to have some type of password in there than none at all since it may be possible for a virus to enable the root user account. I see this as a major flaw in Linux right now.

suicidaleggroll 05-06-2013 02:15 PM

Quote:

Originally Posted by Altiris (Post 4946089)
I see this as a major flaw in Linux right now.

Very few distros operate on the sudo-only principle with the root account disabled. Most Linux distros still make you (or at least allow you to) set up a root password during installation. If you dislike the sudo-only no-root-account way of doing things (you're not alone in this camp), then don't run those distros.

Altiris 05-06-2013 02:16 PM

I've only tried ubuntu based, debain, and then CentOS. I think CentOS is the most secure, anyways my question is answered thanks

tronayne 05-06-2013 02:31 PM

You might want to try Slackware if you want control, stability and reliability.

Oh, you will have a root account and you will be prompted to set a password for it during installation.

Hope this helps some.

eSelix 05-06-2013 02:57 PM

Disabling root login doesn't mean that root privilages are inaccesible. This root account is still needed for other purposes than login to system, like for maintance by user. To enable root account virus or other user need to known administrator password (or somehow other method of authorization to use this account), it is irrelevant which password it would be (root or other account). Passwordless root account has other purpose, like allowing specified users to execute privilaged commands, or commands as another user, without giving them password for root, therefore full access to system.

Also you can't say "all distributions" - not all of them are multiuser (on some of them only root account exist). Also not everyone want disabled root account, it all depends on actual use of system. And for example, on Ubuntu you can choose during installation (precisely a sudo package) if you want to have disabled root account or not.

mreff555 05-06-2013 03:24 PM

Quote:

Originally Posted by Altiris (Post 4946089)
Alright but so shouldn't all distributions when installing allow someone to set a root password and then after installation disable the account? It's better to have some type of password in there than none at all since it may be possible for a virus to enable the root user account. I see this as a major flaw in Linux right now.

If I log in to a brand new system such as debian, as a user with all access in the sudoers I have the ability to set the root password. Even if it has already been set. In my opinion the security flaw is SUDO itself. On a desktop system I prefer to have it for simplicity. I would think that secure servers would be better off without sudo.

TobiSGD 05-06-2013 03:50 PM

Quote:

Originally Posted by mreff555 (Post 4946128)
I would think that secure servers would be better off without sudo.

Secure servers are better off with sudo. But only if it is configured properly, in the way it was intentionally thought, for letting specific users or groups run some specific tasks with root privileges without giving them a general root-access to the machine. Of course, if you are the only person that administers a server sudo usually is unnecessary (and not existent on my servers).
On my desktop/laptops I keep it for convenience, for running some specific commands without the need for a password.

suicidaleggroll 05-06-2013 06:36 PM

Quote:

Originally Posted by mreff555 (Post 4946128)
I would think that secure servers would be better off without sudo.

As Tobi said, secure servers are better off with a properly configured sudo. It enables users to do the operations they need without having to dig out the huge root password every time, which makes things both faster and more secure (fewer people have access to the root password, the root password doesn't need to be accessed as often, etc.). As it's set up on many systems though, with the first user created on the system having full sudo power, it is certainly less secure than without sudo though.

In my opinion, in order of most secure to least secure, it goes:
1) true root user plus properly configured sudo
2) true root user with no sudo (RHEL/CentOS default)
3) no root user and the first user account has full sudo power (Ubuntu default)

mreff555 05-06-2013 06:37 PM

Quote:

Originally Posted by TobiSGD (Post 4946150)
Secure servers are better off with sudo. But only if it is configured properly, in the way it was intentionally thought, for letting specific users or groups run some specific tasks with root privileges without giving them a general root-access to the machine. Of course, if you are the only person that administers a server sudo usually is unnecessary (and not existent on my servers).
On my desktop/laptops I keep it for convenience, for running some specific commands without the need for a password.

While I agree that it would be more secure if utilized properly, which many people do not do. Most of that security can be done simply by fully utilizing groups. Yes, I know it doesn't require a user to enter his password again but that probably isn't really necessary if his only access elevation is to run one or two programs.

Where I think the system becomes insecure, is that if there is more than one user able to set the root passwd, then there is now two root accounts. Twice the opportunities to compromise the system.

nigelc 05-07-2013 02:50 AM

Have sudon't if you don't like sudo.

Ubunbtu is getting more like windows.

TobiSGD 05-07-2013 03:32 AM

Quote:

Originally Posted by mreff555 (Post 4946208)
Most of that security can be done simply by fully utilizing groups. Yes, I know it doesn't require a user to enter his password again but that probably isn't really necessary if his only access elevation is to run one or two programs.

Would work also. But is lacking a feature of sudo that most people simply forget: with a proper configured sudo you can have logging which user used sudo for invoking which command, which can make things much easier for the admin.


All times are GMT -5. The time now is 04:13 PM.