Search code examples
linuxunixubuntu-10.04ubuntu-11.04ubuntu-10.10

can we write a simple bash script to automatically login as root user


I usually have to login in 20 to 50 times daily as a super user, typing the long password again and again..

i have just created a simple bash script

#!/bin/bash

sudo -s
echo password

./test

output root@localhost: password when i execute it, it works like charm... but it shows my password on the screen.....

do some one have any other best solution...... for this small problem.......

i hope this is not all the solution in security standard...... can we have any other solution with out exposing my password.....


Solution

  • You can configure sudo to require a password only every so many minutes. The default is 5 minutes. Read the sudoers man page and scroll down to this:

        timestamp_timeout
                   Number of minutes that can elapse before sudo will ask
                   for a passwd again.  The timeout may include a
                   fractional component if minute granularity is
                   insufficient, for example 2.5.  The default is 5.  Set
                   this to 0 to always prompt for a password.  If set to a
                   value less than 0 the user's timestamp will never
                   expire.  This can be used to allow users to create or
                   delete their own timestamps via sudo -v and sudo -k
                   respectively.