Slashdot Mirror


Got Root - Should You Use It?

vegthura asks: "I have several coworkers that insist that logging into servers is an acceptable practice. They claim it's just easier than using sudo and it's just as safe - you know you're root so what else do you need? And why bother logging in as you if you're just going to use sudo to run commands with root privileges anyway? Everything I've ever read has been the exact opposite philosophy. There is very little you need to be root to do, if anything in practice, and using sudo lets you only use the power of root for when you really need it. So, die hard unix geeks, you've got root... do you use it or stick to sudo?"

50 of 245 comments (clear)

  1. Sudo wins for me by Smitedogg · · Score: 4, Informative

    Using sudo, you can allow 'some' root commands to other users/admins without opening up the vault, and you can do a lot of smart things like keep root unable to be logged into, or have a true strong password that you can lock in a safe somewhere, all without losing functionality.

  2. More than just root by Sentry21 · · Score: 5, Informative

    Using sudo provides a host of benefits besides giving you root. Sudo allows you to grant access to specific users for specific commands, and then revoke those commands later. Compare this with giving the root password to everyone, which requires the password to be changed whenever someone leaves the company (or someone's root privs are revoked).

    I can grant access via sudo to users for specific commands, without giving them complete administrative access to the entire system.

    When I'm using 'sudo' to do things, my environment stays the same. This means that my $PATH variable stays the same, and so does my prompt. It means that any time I say ~ it refers to /home/myusername and not /root, meaning I can get to it later.

    When I'm not using sudo and I do 'cd /var/www/certs/domainname/' and it doesn't give me an error, I know that the permissions are wrong on that directory (more of a reminder than anything). I've gotten so used to this on most systems that the series of commands I use to access the IMAP virtualhost directory is essentially 'cd /var/spool/postfix/virtual; sudo bash; cd /var/spool/postfix/virtual', which slows me down surprisingly not much.

    It doesn't take much to hit the up arrow, Ctrl-A, type 'sudo ' and then hit enter if you find you need to.

    I can set in ~/.bash_profile that I want rm to use -i by default (alias rm='rm -i') for safety, which carries over into my 'sudo' environment; doing this for root by default can cause e.g. cronjobs to hang, waiting for input that will never come.

    The benefits of sudo are not limited to 'gaining root' - they are multitudinous, and apparently your coworkers have never considered versatility to be a benefit; nor, for that matter, have they done likewise for security. Perhaps they should be educated.

    1. Re:More than just root by Henry+V+.009 · · Score: 2, Interesting
      There are benefits to using sudo, and depending on the situation some of those may become very important. But one con I'd like to point out is the dependence on the sudoers file. You can mangle a system (requiring a reboot to single-user) with one wrong entry. And if you are constantly editing it to give users fine-grained privileges, that risk is important to weigh against the benefits.

      And if (as with my current job) you work someplace with:
      1. Low employee turnover.
      2. Lots of servers.
      3. Few people with root access.
      4. LDAP authentication for passwords to make changing the root password on all servers easy.
      Then maintaining seperate sudoers files on every server is far more pain than it's worth.
    2. Re:More than just root by Deorus · · Score: 3, Insightful

      > Compare this with giving the root password to everyone, which requires the password to be changed whenever someone leaves the company (or someone's root privs are revoked).

      Create multiple UID 0 accounts with different passwords.

      As for the rest of your post, I'd rather not trust the security of a server to sudo, firstly because it had security issues in the past, and secondly because it's not a trivial task to decide which commands a user can and can not have access to.

    3. Re:More than just root by c0nman · · Score: 2, Informative

      sudo bash ???

      Do people actually do that? If you want a root shell it's sudo -s. But that is NOT the purpose of sudo. You want accountability on your server(s).

      And as pointed out by another already, sudo !! or sudo !-2, sudo !-3, sudo !command... Understanding your environment should be one of the first things you learn.

      user/server:/path$ vi /var/named/chroot/var/zones/master/d/domain.tld

      "/var/named/chroot/var/zones/master/d/domain.tld" [New File]
      user/server:/path$ ls -l /var/named/chroot/var/zones/master/d/domain.tld
      ls: /var/named/chroot/var/zones/master/d/domain.tld: Permission denied
      user/server:/path$ sudo !!
      sudo ls -l /var/named/chroot/var/zones/master/d/domain.tld
      -rw-r----- 1 named wheel 7185 Aug 6 2005 /var/named/chroot/var/zones/master/d/domain.tld
      user/server:/path$ ^.^2.
      sudo ls -l /var/named/chroot/var/zones/master/d/domain2.tld
      -rw-r----- 1 named wheel 1121 Aug 6 2005 /var/named/chroot/var/zones/master/d/domain2.tld
      user/server:/path$ sudo -s
      root/server:/path# id -p
      login user
      uid root
      groups wheel kmem sys tty operator staff guest
      root/server:/path# ^D
      exit
      user/server:/path$ tail -n3 /var/log/secure
      tail: /var/log/secure: Permission denied
      user/server:/path$ sudo !!
      sudo tail -n3 /var/log/secure
      Apr 15 22:10:54 server sudo: user : TTY=ttyp1 ; PWD=/path ; USER=root ; COMMAND=ls -l /var/named/chroot/var/zones/master/d/domain.tld
      Apr 15 22:10:55 server sudo: user : TTY=ttyp1 ; PWD=/path ; USER=root ; COMMAND=ls -l /var/named/chroot/var/zones/master/d/domain2.tld
      Apr 15 22:10:57 server sudo: user : TTY=ttyp1 ; PWD=/path ; USER=root ; COMMAND=/usr/local/bin/bash

      That's right, we don't have our user associated with our commands when in a root shell via sudo. There are patches and shells that will log this information, but they should not be needed. Correctly using the tools are as important as the tools themselves.

      You will ALWAYS want to have individual logins for every administrator and TEACH your admin's howto use sudo correctly if they do not know already.

      As for the original question: nobody should EVER login as root, EVER, PERIOD.

    4. Re:More than just root by teknomage1 · · Score: 2, Insightful

      Isn't the sysadmin's job to decide which commands a user can and can not have access to?

      --
      Stop intellectual property from infringing on me
    5. Re:More than just root by JollyFinn · · Score: 2, Informative
      As for the rest of your post, I'd rather not trust the security of a server to sudo, firstly because it had security issues in the past, and secondly because it's not a trivial task to decide which commands a user can and can not have access to.

      rm -rf /

      bash -c select X in ls /* -A; do{ select Y in ls X; do 777 > Y ;cd ..};#My first shell script probably buggy but gives idea what it should do

      emacs -f (delete (recursivegeneratepathtoallfiles "/"))

      vi -c #Too tired to do the damanging function but still it could be done.

      rm, bash, emacs, vi, are out of limits expecially last 3 since those 3 can generate what ever sequenceas you could consider. There are plenty of other programs that should be out of limits for normal users to get sudo.

      --
      Emacs is good operating system, but it has one flaw: Its text editor could be better.
    6. Re:More than just root by Znork · · Score: 2, Informative

      "Sudo allows you to grant access to specific users for specific commands,"

      Perhaps a nitpick, but be _very_ careful with that slight misconception. The correct statement would be:

      Sudo allows you to grant root (or other) UID to specific users for specific commands.

      On the surface it appears a slight distinction, but it means that seemingly innocent commands like vi or more lets users do shell escapes to obtain root shells, cat with sudo priviliges can allow them to overwrite passwd, etc.

      Basically, while using sudo, it's safest to assume that any user granted access as root for any command through sudo can obtain general root priviliges, should they so desire.

    7. Re:More than just root by Bert64 · · Score: 2, Insightful

      So i assume you also won't trust the security of your server to an even greater degree to an OS that's had security issues in the past...
      So, what OS are you running?

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  3. Sudo by doon · · Score: 4, Informative

    I even use sudo on my *nix boxes @ home. I am a firm believer in sudo. mainly since if I do something stupid with it, I have a log of what it was. We also use sudo at work on all of our boxes(40+), to me it just makes it easier, and makes for one less password to remember. ALso the majority of tasks that I need to do, I can do as myself, there are some tasks, such as restarting services,etc that I need root to be able to do, so as opposed to su'ing over to root, (we don't allow root logins), it is just as easy to sudo the command. Once we get around to hiring a Jr admin, we will use sudo to limit what they can access.

    --
    To E-mail me, replace the first period in my domain with an @
  4. I stick to sudo by gzearfoss · · Score: 5, Insightful

    I personally stick to sudo. The main reason why is to protect me from myself, more than anyone. Because I have to prefix the command with sudo, it serves as a 'mental brake' to slow down my typing, and double check what I type before I run it.

    1. Re:I stick to sudo by Tragek · · Score: 5, Interesting

      See; in theory, its a great idea. But by the same principle that some nerds start typing digg when they mean dig, and del.icio.us when they meant delicious, I manage for the most part to disable the mental brake that stops me from using sudo wishywashily. I type sudo rm -r * with the same ease that I type rm -r. My hands muscle memory once started is faster than my brain. I guess I just have to trust that my initial aim is true.

  5. It depends... by D'Arque+Bishop · · Score: 5, Interesting

    For me, it all depends on whether or not the machine is one I directly own or control.

    If it is one I personally own or am more or less directly responsible for above anyone else, then I use root if needed.

    If it's one that I don't personally own or I'm reporting to someone else who's ultimately responsible for the machine, I don't ask for the root password and request sudo access instead. That way, there's a log of my actions so I can go back and show exactly what I was and wasn't responsible for doing. Showing accountability is key when you're in a position of trust, IMHO.

    Just my $.02...

  6. Ask slashdot; by jericho4.0 · · Score: 5, Funny

    My brother insists it's safe to turn off a computer by pouring beer on the power supply. Everything I've ever read has been the exact opposite philosophy. Who is right?

    --
    "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
    1. Re:Ask slashdot; by enrgeeman · · Score: 2, Funny

      not root beer, sudo beer!

      --
      sent from my slashdot browser.
    2. Re:Ask slashdot; by EZLeeAmused · · Score: 4, Funny

      Your brother is right. It is safe and effective to turn off a computer by pouring beer on the power supply. But it only works once. And after it does, you really wish you still had that beer.

      --
      Some see the vessel as half full; others see it as half-empty; We pour it out on the floor and laugh
    3. Re:Ask slashdot; by OldManAndTheC++ · · Score: 2, Insightful
      Surely it is best to drink the beer and then urinate on the power supply. Admittedly this increases your risk of electrocution, but at least you are not wasting beer!

      P.S. you seem to have found an exception to my sig ...

      --
      Soylent Green is peoplicious!
  7. It's all about logging by forsetti · · Score: 5, Insightful

    Given rich ACLs, there is really very little that needs to be done as root. However, when root is needed, it is important to remember that there is only one root. On a machine with multiple admins, how do you tell who logged in as root? The sudo log entry tells all:

    Apr 15 22:05:41 linux-black sudo: matt : TTY=pts/0 ; PWD=/home/matt ; USER=root ; COMMAND=/usr/bin/tail /var/log/auth.log

    sudo is valuable if only for the logging. Yes, you can limit what can be done using the sudoers file, but logging who did what is invaluable.

    --
    10b||~10b -- aah, what a question!
    1. Re:It's all about logging by lord+sibn · · Score: 2, Informative

      $ sudo bash -c 'echo "Apr 15 22:05:41 linux-black sudo: person_you_hate : TTY=pts/0 ; PWD=/home/boss ; USER=root ; COMMAND=/bin/rm -rf /path/to/the/bosses/files" >> /path/to/the/log'

      you do, of course, realise, that this command will be appended to your freshly deleted log?

  8. Turn Off Remote Root by Erwos · · Score: 3, Informative

    Whatever you do, DO NOT allow remote root logins. Ever!

    root is the one account that attackers can be reasonably sure exists on your computer. Allowing remote access to it allows them to hammer it with dictionary, brute force, and social engineering attacks from relative safety.

    If you're the only admin on the computer, su into root is fine - if anything goes wrong, it's your fault anyways. Otherwise, use sudo to maintain high levels of auditability and least privileged access.

    -Erwos

    --
    Plausible conjecture should not be misrepresented as proof positive.
    1. Re:Turn Off Remote Root by mcrbids · · Score: 2, Informative

      Whatever you do, DO NOT allow remote root logins. Ever!

      Unless you login via SSH with RSA keys

      root is the one account that attackers can be reasonably sure exists on your computer. Allowing remote access to it allows them to hammer it with dictionary, brute force, and social engineering attacks from relative safety.

      Not if you're using RSA keys.

      Whether to use sudo depends on your role within your organization. I'm the sole admin of a small company, so I use root. If something stupid was done, it'd come right back to me, anyway, so what good is the logging?

      And, I don't bother with passwords - they're too easily guessed and too hard to remember, and trying to keep 31 different passwords for NNN account on YYY server gets crazy real fast.

      But, with RSA keys, I have no passwords to remember, and furthermore, I'm all but invulnerable to dictionary attacks and the like. I'd further recommend moving your SSH daemon to a funky port, so that automated scans don't see your potentially vulnerable hole.

      My Linux laptop has RSA keys set up for each server, so it's a single command to become root on any server.

      We just hired our first tech employee, and I can assure you that *he* won't be getting so much rope for a while - he'll be using sudo *IF* he needs root power, and then only on the dev server. Eventually, if he steps up to the plate, I'll gie him some more administrative privs, but that's a ways off...

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
  9. Wrong by metamatic · · Score: 3, Informative

    Good practice is to avoid running server tasks as root unless absolutely necessary, and there are all kinds of server admin tasks you might need to do, that don't need to involve becoming root. Database administration, for example.

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    1. Re:Wrong by nagora · · Score: 2, Interesting
      and there are all kinds of server admin tasks you might need to do, that don't need to involve becoming root. Database administration, for example.

      All normal database admin can be done with various programs that access the server remotely (by which I don't mean ssh!). Abnormal admin that requires actually logging into the server pretty well always requires root. The same goes for everything else.

      It is true that the daemons should not RUN as root but by and large every one of them needs root to do anything drastic to their configuration or rescue data in the case of a crapped-out drive. For everything else there's SWAT, CUPS, phpadmin, even good old Webmin & co. All these use HTTP in one way or another and reduce the day-to-day need to login to zero.

      There's just no need to be on your server unless you are root.

      TWWW

      --
      "Encyclopedia" is to "Wikipedia" what "Library" is to "Some people at a bus stop"
    2. Re:Wrong by kpharmer · · Score: 2, Informative

      > All normal database admin can be done with various programs that access the server remotely (by which
      > I don't mean ssh!). Abnormal admin that requires actually logging into the server pretty well always
      > requires root. The same goes for everything else.

      > There's just no need to be on your server unless you are root.

      Hmmm, i've got to disagree. What database product are you thinking of?

      I'm using db2 to manage a large data warehouse & set of reporting databases. DB2 is notorious for requiring root, but even here:
          - root is required to install or uninstall db2 or its fixpacks
          - root is required to run a few odd utilities

      and that's it. Server admin can be run remotely by db2 java clients, but most suck as much as Oracle's OEM, etc. This is usually used by junior dbas with no unix skills. Limited server admin can also be performed remotely over command line. Limited.

      So, most server actions are then performed locally by a dba without root or sudo:
              - start server
              - stop server
              - backup database
              - load table
              - check tablespace container allocations
              - add/remote containers (files, devices, file systems) from tablespaces
              - check memory utilization
              - check process utilization

      I've seen a few organizations that refused to allow dbas to login to their database servers. On closer inspection I discovered that all databases that the organization supported were trivial: less than a 1 gbyte of content-management stuff, or 50 mbytes of transactional data. Needless to say I didn't move multiple terabytes of reporting data into their environment - to be at the whim of their untested theories on what a dba needs to do.

  10. Re:Simple solution by dshaw858 · · Score: 2

    I do this on all of my servers. And even more, there's this great command if you really need a root shell:
    sudo su

    Amazing, isn't it? You can login as you and still spawn a root shell if you really need to.

    It's easier that way.

    - dshaw

  11. Got Root - Need Root by Ajehals · · Score: 4, Interesting
    (Disclaimer, its 3 am, I've just given up doing a code audit on the basis that I am too tired, so if this doesn't make sense, I am sorry, oh and don't take my advice or even think about relying it the following statement is as is, and comes with no warranty - would be first post but its taken me half an hour to write this.. :) )

    When you are logged in as root you have unlimited access to all files, and it is possible to remove or modify a file that is vital to the system, this is generally not good, and often not required. If you set up a server securely you should be able to create accounts that have the access that you require to carry out specific tasks (still preferably using sudo, or su'ing to the relevant account), this is as much a common sense measure as pure security precaution.

    You could argue that you can log in as root as long as you avoid using wild card designators when executing commands and keep track of your current working directory and try not to mess anything up, but there are a load good reasons to use sudo or su to root (or preferably an account specified for a task) instead, here are the ones I find most important:

    Firstly you get some accounting, if Joe Bloggs su's to root and breaks / steals / misconfigure's something, at least you know it was Joe Bloggs (or someone using Joes account)

    Secondly if you have remote access only as a non root user (this should be a given, never log in via ssh or webmin or whatever as root, (it can be a nightmare when you think your on system A but are on system B and do something you didn't mean to, never mind as root...) any attacker is going to have to find a non privileged account to gain access to a system, and then gain root privileges..

    Thirdly if you have set up a number of administrative users for specific tasks you can compartmentalise your systems maintenance and you don't have to give someone you don't trust root access to carry out basic maintenance.

    Lastly, the less you use your root account (directly or by whatever means) the less likely you are to break it. Lets be honest, I'd love to log in as root all the time, it would make life easier, but it would get rid of quite a few of the security benefits Linux/Unix brings and I'd probably break things more often. If you get used to using the root account you will continue to use it more and more until you find yourself logged in as root surfing the web whilst playing some bzflag beta just waiting for someone or something to break your box. (not to mention the hours you would spend making it possible to log in as root and use all your apps that are (probably) not going to like being run as root).

    Personally when I set up a secure server I try to ensure that I have users with the relevant rights set up for specific tasks and no more and only issue those accounts to users who require them. I mount as many of the file systems as possible read only, I try to ensure I ship log files out to a box that no-one with root privileges on the first box has access to, and I automate as many of the maintenance tasks as possible. Oh and I don't use sudo, and on hyper critical servers the full root password is known to no one, I have half my oppo has the other half, and never the two shall meet (although this causes inconvenience when you do need it...!!)

    This prevents foul ups and gives you a security baseline.

    Oh and if you do log in as root make sure its not ever into a Desktop Environment (or any complex environment really) because there are just too many apps executing as root at that point to keep track of properly, and way too many potential security vulnerabilities...

  12. Using Root. by run4ever79 · · Score: 2

    There is an expression that goes way back, "The amount of time that you spend logged in as root is inversely proportional to your competence as an admin." Once a machine is configured, there are only a small number of legitimate reasons to login as root, and nearly all of these can be more safely done using sudo as others have mentioned. For a good treatment of this see: http://www.theregister.co.uk/2006/02/24/bofh_2006_ episode_8/ . Also as previously mentioned root should _NEVER_ be able to login remotely. You might as well set up your DNS to name your box pleasehackme.domain.com. (Although you can rename the super-user account, which can be tricky to do right).

    --
    Linux : Hotrod :: Windows : Yugo
    1. Re:Using Root. by fimbulvetr · · Score: 2, Interesting

      He who plays with root, will soon kill tree.

      Someone other than me deserves credit for this oh-so-true statement.

  13. Re:Use sudo rarely? by techno-vampire · · Score: 5, Informative
    Maybe I am missing something somewhere, but the 'use sudo if you absolutely need root' is crap.

    You are. The right way to say it is, "Use sudo if you only need to run one command as root; log in as root only when you're going to need to do a number of things that require root."

    As a side-note, somebody upstream noted that sudo doesn't change your environment, but becoming root does. If you don't need root's environment, just use su, instead of "su -" and you keep your current location, $PATH and other things.

    --
    Good, inexpensive web hosting
  14. sudo means no password sharing by shift · · Score: 2, Interesting

    I hate coming into a place and finding out that passwords for accounts like root are shared. Its also a real pain when someone leaves the company. Where I work, we've basically tossed out the root password and grant access with sudo. We just have to disable accounts when someone leaves and not scramble to change a password then make sure every who needs to know is notified.

  15. Sudo, Generally, But .. by hbo · · Score: 3, Informative
    I use sudo routinely, for many of the great reasons outlined above. But how do you do egrep '^From: Postmaster' /var/spool/mqueue/qf*" with sudo?

    You don't. Globbing is broken because the shell does it before sudo is run. This gets around the problem:

    sudo "sh -c '(cd /var/spool/mqueue;egrep ^From:\ Postmaster qf*)'"

    That works, but it's ugly, and I have to be able to invoke the shell with sudo in the first place.

    I/O redirection is similarly broken. sudo grep root ~/cron_jobs >> /etc/crontab will fail because your shell will do the I/O redirection, not the sudo enabled grep. This works:

    grep root ~/cron_jobs | sudo tee -a /etc/crontab >dev/null

    This time, tee is the one appending the output, not the shell.

    I use these workarounds with sudo quite a lot. It seems I need the latter more often than the former. But I stick with sudo regardless, for the shell environment consistency, and the ability to go back and see what I did wrong 12 hours after the 36 hour hacking session ended.

    --

    "Even if you are on the right track, you'll get run over if you just sit there" - Will Rogers

  16. Why do they have root? by NNKK · · Score: 2, Insightful

    If they're not a sysadmin, they don't need the root password. They probably don't need sudo, either. If they have the former, your internal policies are broken. If they have the latter, you better be damn sure of why. sudo is far from foolproof. It's almost exactly like making select binaries suid root and available only to a specific group, except that it's more convenient (good), and introduces an extra suid root binary that could have a security bug (bad).

    If they are a sysadmin, and we're talking production servers, they're either qualified to decide what's best for their particular situation, in which case you really don't need to be questioning them (if their judgement isn't trustworthy, what the HELL are they doing in a sysadmin position?) and you're just wasting everyone's time, or they're just generally incompetent, in which case either the IT department will eventually be taken over by someone competent and the house will be cleaned, or the company will die a slow and painful death. Either way, it's all pretty moot.

    Make sure your resume is up-to-date.

  17. sudo is all wrong by r00t · · Score: 3, Insightful

    Sudo adds complexity where you least want to have it. A config file that you can mess up? No thanks.

    Plain old su works well. It leaves a log, via the shell history file. You can adjust the history file size if needed. If you want a secure and uneditable log, neither will do. Breaking out of sudo is easy; normal command-line software is not designed to keep you in the setuid-like environment that sudo provides. Regular old apps will have buffer overflows, which are not considered security holes... until you go making the apps setuid or - equivalently - letting them be run via sudo.

    If you'd be tempted to leave yourself su to root, first open a second window. Now you have one window for root-only stuff, and one window for everything else. Change the font or color or window title if you need help remembering.

  18. Nah, viruses don't need root by r00t · · Score: 2, Informative
    Think about what a virus does these days, remembering that few machines are truly serving multiple people.

    • It wants a network connection. Normally, every user has access to that.
    • It wants your email client config. As root, it would need to do more searching to find this.
    • Supposing you use SE Linux, it wants your SE Linux privs. Perhaps root has been restricted.
    • It wants a place to store itself: ~/.something-that-looks-legit
    • It wants a way to activate itself: GNOME session startup files, .bashrc, .bash_profile, cron job

    So far, I've only found one moderately-useful thing restricted to root: the SYN-flood DoS attack. That's no big deal.

    A virus certainly doesn't need to patch the kernel or write to /bin. Those are cool tricks of course, but they don't gain any significant resources and aren't necessary for hiding from normal people.

  19. It sounds like you are not really using sudo by Error27 · · Score: 2, Funny

    It sounds like you can't really articulate a need for sudo but you're just doing it because you read about it. Sudo isn't magically better if you don't use the features.

    Also it annoys me that sudo seems to have a lot of security bugs. It had 3 local exploits last year... That doesn't affect whether you should use it or not because you obviously should, I'm just saying that it annoys me.

  20. Sudo's intended use by RomulusNR · · Score: 2, Interesting

    Sudo's main benefit IMO is to keep unattended terminals and non-password-based attacks from being no-brainer vectors to root. It's not to make it a pain for you to have to type a password just to run root commands; its to make it so that the user is able to run certain root commands and making extra sure before doing so that it is really that user running them (not a hijacked terminal, etc.)

    The other benefit is that it allows you to pick and choose who needs access to what root privileges. Junior data center tech A doesn't need access to fsck(), but maybe needs to be able to mount /dev/sdc. (OK, poor example.)

    Sudo isn't IMO the solution for all admins, though; extensive admin work quite necessarily can be done with su to root instead. Sudo allows you to keep the root password on a tight leash -- preferably to those who can be responsible with their sessions as well as with root powers.

    --
    Terrorists can attack freedom, but only Congress can destroy it.
  21. root or root not; there is no try by Tumbleweed · · Score: 5, Funny

    Look, if you're too much of a pussy about using root because you might screw something up, you shouldn't have the root password anyway, should you. *pbbt* :)

  22. Logging Who's On. by Stephen+Samuel · · Score: 4, Informative
    If you've got a half dozen (or dozens of) people who have root login, and something goes on, all you have with a quick look at the log is that someone logged in at 4:15 pm and the system choked at 4:18.

    If you force people to login as themselves and then SU (or sudo), then you know who was on the system with root when the system snarked ( And, if they use sudo instead of su, you can even have logs of the commands they used) -- it cuts down on the number of people you have to interview in the rush to figure out what broke the system.

    Then, there's also the fact that if someone tricks you into doing something 'bad', it's less likely to catch you flatfooted as root if the only commands you exeute as 'root' are the ones that really need root.

    As a last point: If you disable root logins (especially remote root logins), then a hacker needs to hunt down two passwords to get root access -- one for remote access and the other to get root.

    Security isn't about making it impossible for an intruder to get in -- It's about making it hard enough that an attacker gives up and goes away -- even if they just go find an easier target (hi bill!).

    --
    Free Software: Like love, it grows best when given away.
  23. Audit trail by horatio · · Score: 4, Informative
    In addition to the things the parent mentioned about privilege seperaration and permissions, sudo (if configured correctly) gives you an audit trail of what was done by whom and when. If someone fscks the database server, you'll know exactly who to beatdown and where to look for a restore point in your backups.
    Apr 16 01:30:30 karma sudo: joeuser : TTY=pts/0 ; PWD=/home/joeuser ; USER=root ; COMMAND=/usr/bin/tail /var/log/auth.log
    It will also let you know if someone is trying to do something you haven't authorized for them in the sudoers file.

    On systems where I'm the only user, I almost always use a non-root account to do normal tasks. sudo lets me elevate privileges for the command I need to, ie
    $ apt-get install reallycoolwidget
    , and then drops back down so I don't forget to exit myself. sudo (generally) does not require you to retype your password for every command, there is a timer. If you're dumb|busy enough to walk away and leave your terminal unlocked, after a few minutes the next sudo attempt will ask for your password again.

    One thing to remember, use visudo, not vi /etc/sudoers. The syntax check will likely save your ass one day.
    --
    There is very little future in being right when your boss is wrong.
    1. Re:Audit trail by TilJ · · Score: 3, Interesting

      If you're serious about the auditing functionality, you need more than just sudo.

      Doug Hanks, a SAGE member, started with sudosh (http://sourceforge.net/projects/sudosh/) and now has released Enterprise Audit Shell (EAS). There's a very basic web page and PDF at http://download.strchr.net/, as well as a nice graphic explaining how it works (http://download.strchr.net/eas-layout.png).

      Copying from the text of the email announcement a few weeks ago, the list of improvements over Sudosh includes:

      * Conforms to COBiT
      * Utilized ITIL best practices
      * Enterprise-view of UNIX access
      * Enterprise-level audit reporting tools for Sarbanes-Oxley
      * Customizable audit reports via CSS
      * Embedded transactional, ACID-compliant SQL92 relational database
      * Load balancing
      * Disaster recovery
      * SSL encryption
      * SSL Public Key Infrastructure authentication
      * Audit file transfers and remote command execution when used as a login shell
      * Configurable default shels
      * Audit logs are digitally signed for integrity
      * Client and server configuration files for easy management
      * Idle session timeout
      * Display corporate policy before eash session

      It looks like a serious auditing tool for serious Unix shops.

      For simpler needs there's also Kerberos `ksu` as a replacement for sudo, for shops that have already solved their centralized authentication.

      --
      "The purpose of argument is to change the nature of truth." -- Bene Gesserit Precept
  24. Re:Simple solution by drsmithy · · Score: 3, Insightful
    I do this on all of my servers. And even more, there's this great command if you really need a root shell: sudo su

    Congratulations. You have now completely removed almost every reason for using sudo in the first place.

    If all you use sudo for is starting a root shell once you've logged in, then save yourself the hassle and just login as root, because you're circumventing basically every benefit sudo offers.

  25. Re:Simple solution by jessecurry · · Score: 2, Informative

    sudo su will just drop you into a root shell, but up until that point by forcing people to use sudo you gain a log of all the commands that they pass off with root privileges.
    Unfortunately once someone gives the sudo su command all you see in the logs is an indication that some grabbed a root shell. I guess that it's a matter of personal preference, but I like the sudo method. I do login as root on occasion, but I like the extra warning that I might be breaking something with a chmod or mv.

    --
    Those who know, do not speak. Those who speak, do not know. ~Lao Tzu
  26. Never give developers root ... by dustpuppy · · Score: 2, Insightful

    In my experience as a dedicated sysadmin working for a huge multinational, every time developers are allowed to have root access to a system, they produce the crappiest application code ever.

    Applications that *require* root access to even run and require sub-apps to be root as well. They are slowly getting better (but only because in the last few years we've enforced a policy of no root access to developers).

    IMHO, root access encourages sloppy behaviour (in both developers and sysadmins) and it becomes an essential crutch rather than an 'only as needed' facility. With the focus on security, and the requirement to participate in regular security audits (SOX anyway?), it simply suicide to give developers root access.

  27. Re:SuDo? never.. by Russellkhan · · Score: 2, Informative

    Among the many things wrong in your post, let me point out that disabling root does not imply giving all users full sudo access. In Ubuntu, your example distro, only the first user created has sudo privileges, unless they are specifically added to another account.

    --
    Information doesn't want to be anthropomorphized anymore.
  28. Security of a normal Account by LABarr · · Score: 2, Interesting

    I read all the previous posts to this discussion and recalled another glaring obvious reason why you should use sudo vs. root logins. No one has brought this up yet, but when you step away from your desk for that quick trip to the john, and then get snagged for that impromtu 20 minute meeting in the hall, away from your desk the whole time, and you leave a root terminal open on your computer, you really are just asking for trouble. Remember that the largest percentage of security breaches occur from within, not outside the company. At least when you use sudo (as is almost always considered best-practice) from your normal user account, you aren't leaving the door totally wide open when you are away from your desk. Sure, I know all about locking your your display, (which I personally do) even automatically via a screensaver, but the again I have also seen a lot of scary simple root passwords as well. Sloppy habits make sloppy admin'ing. I admin my personal servers as well as any for anyone else via sudo. Another vote soundly in the sudo column.

    Sudo and the less voodoo you do to whom?

    ___
    Simulated sig.

  29. Sudo weakens security by jurgen · · Score: 4, Informative
    The main problem with sudo is that it weakens security.

    It seems that this is surprising to a lot of people because nobody has mentioned this, and people have mentioned that you should never allow remote root logins, yadda, yadda.

    Actually there is no problem with remote root logins via ssh and public key authentication... just don't use/allow passwords. I'm continually amazed by how few people understand this, especially considering that practically everyone and their dog already uses ssh for everything anyway (except they use it as though it was telnet... doh!). Ssh is the best thing that ever happened to Unix security, but 99% of people, including sysadmins it appears, use only 1% of its power because they do not understand public key authentication. But I digress...

    Passwords are almost always security's weakest link, unless you have truly exceptional password discipline (i.e. chose a good (long, random) pw, have a different one for every account, use it only in safe contexts, never, ever, ever share it even with your twin-sister-wife-best-friend, never write it down, etc). The problem with sudo, from a security standpoint, is that it adds the weakness of every sudoer's password to the root account. Think about this... the INSECURITY of your root account is increased by the sum of all the weaknesses and password in-displine of all your sudoers.

    Let me say this again... with sudo your root account's password security is worse than the worst of the passwords of all the sudoers, it accumulates all the weaknesses, all the indiscretions of all your sudoers.

    And don't give me any crap about limiting what commands a sudoer can invoke... with sudo any command/program that isn't specifically written to be a /secure/ SUID program is a conduit to root. To give you only the trivial example, you can't do much sysadmin with editing some root-only files, and most editors have a shell-out function. The moment you give anyone usuful sysadmin capabilities using sudo you've made their password a root password.

    To their credit most of the people who wrote here that they like sudo like it for the convenience of logging priviledged actions. This is certainly a good practice. Just understand that it is a PRACTICE, not a security feature... if someone wants to get around it, they trivially can. If you want to log for security you have to do it in the kernel and most Unix kernels have such features nowadays.

    So, if you want convenient logging of your own actions, go ahead and use sudo. If you want to /improve/ security, keep it away with a 10-foot pole, minimize the use and impact of all passwords, and use Ssh.

    Btw., some ssh implementations can do everything you /think/ you're doing with sudo, such as limiting access to commands to certain users, logging actions, etc. Ssh is the swiss army knife of unix security... it can also be misused, but if you learn how to use it correctly and to its full extend you can stop using passwords and /dramatically/ improve your system security.

    :j

    1. Re:Sudo weakens security by jurgen · · Score: 2, Insightful
      rvim is useless. It's not enough to prevent shell-out... that's why I said that was a trivial example. You also have to restrict what files can be edited; for example if I can edit any file that will later get executed or included in a script run as a root I can give myself a root shell... I just add a line that sets the suid bit on an exe I have stashed away somewhere. You could add such a line to i.e. one of the sysconfig/network-scripts/. Since almost all unix system administration involves editing such files, again sudo is useless for general system administration.

      The moment you use sudo for more than granting some highly specific operator-level priviledges, such as say starting a backup job, your root security is guaranteed to be weakened by it. And even if you think you /are/ very careful, unless you are a real unix security expert you're probably overlooking something.

      :j

  30. It's not about the root access... by TBone · · Score: 3, Informative
    At every mid-to-large company I've worked for (the smallest being a 500 person company that runs some little websites like CingularExtras.com), the problem isn't the root access - they hired you, you work there, and you have the trust to do what you need to do in order to perform your assigned tasks. In the end, whether you do that as root, or as bsmith who runs "sudo su -" or even "su -" doesn't really matter.

    What does matter, is accounting for which user ran that "rm -rf /mnt/financialReports" and isn't owning up to it. Or which user made system tuning changes that don't seem to be working right. Or any number of things which may or may not be malicious, but need questions answered.

    None of the companies I worked for put sudo on servers to limit what their sys admins could do - they put it on the systems so that they could, if something were to happen, figure out which of their admins they needed to go ask questions of. Files are missing, what were you doing. Server isn't behaving right any more, what was the last thing you worked on.

    You can't do any of this (easily) if 5 admins are all logging in as the same user. You can do it fairly trivially if you're logging in as your own id and switching to root.

    --

    This space for rent. Call 1-800-STEAK4U

  31. sudo every time by Grimwiz · · Score: 2, Informative

    sudo provides much more than su...
    1. It authenticates against the same password that you logged in with, not only saving you from learning two, but allowing you to keep the root password secret.
    2. It doesnt always have to allow access to root, "sudo -u user" can be used to give application/db access.
    3. sudo remembers your access for a little while, allowing you to single-shot commands, causing less irritation than "su -c"
    4. You can control it remotely, e.g. by active directory group. This allows centralised user administration of system admins.
    5. You can provide privileged access of single shot commands to batch processes.

    --
    -- Don't believe everything you read, hear or think
  32. For me it is about passwords by YoungHack · · Score: 2, Informative

    No one ever seems to mention this, but for me I use su with the coworkers who have root access. Reason? Pure and simple, I get to set the root password, and I set it hard. For various reasons having to do with parts of the computing environment I don't control, I can't have the same confidence about non-root passwords.

    Using su instead of sudo puts one more barrier in the way. If you cracked a regular user account with liberal sudo access but a weak password, the same weak password gets you to root. That isn't true with su.