Perl Tricks

In my environment there are some commands I need to run as “true root”, which means I have to login to the server as root… no su or sesu. We have all of our Unix/Linux servers locked down for root access via SSH, so every now and then I need to open root temporarily in order to login as root to run some commands. I got tired of manually editing sshd_config and restarting the service just to re-do every change I just made. Here is a couple of Perl one-liners that will do the job for me.

This will un-lock root access via SSH and restart service:

This will lock root access via SSH and restart service:

For Unix servers you will need to restart the service using code below:

This one-liner can be modified to automatically edit any config file.

Linux, Perl Scripts
Tags: , ,

Leave a Reply

Comment
Name*
Mail*
Website*