sâmbătă, 26 noiembrie 2011

Protect your root account.

I will present a solution to protect the root account, quite funny but still elegant.
You can read about the command trap using : man trap.
What is this command?
when the specified event will occur will execute the command specified.
In this case, it will receive signal respectively will execute one command - exit
The the source code.

 echo "What is the secret ?"
 trap protect 2 20
 read -s resp
 if [ "$resp" != "asd" ]; then
 echo "Error!"
The result will be leaving the root account if you do not answer the question correctly.
Now protect the file against unauthorized changes:
# chmod 700 /root/.bashrc
You can create using the example above, different ways to execute various commands.

4 comentarii:

Stanislav Ochotnicky spunea...

Ehm...what is this supposed to protect?
$ su -
What is the secret ?

$ su - -c /bin/sh

Catalin Festila spunea...
Acest comentariu a fost eliminat de autor.
Catalin Festila spunea...

I try your "su - -c /bin/sh" and is not give me acces on root so the function from .bashrc working well on my Fedora ...

Michael spunea...

Thanks for sharing!

Trimiteți un comentariu