Archive for the ‘unix’ Category

Utility Bash script to setup key based ssh access quickly

Saturday, January 14th, 2012

I needed to add my public key to a couple of servers the same day. After having done it twice, I thought of writing a bash script to pull my key from a public url at dropbox and append it to the authorized_keys file on the server. It appends to the same user who I am logged in as.

You can build on this if you find yourself doing something similar repetitively.

delete rails sessions on linux

Wednesday, May 10th, 2006

By default Rails creates session files under {RAILS_ROOT}/tmp/session
Use this script to remove sessions more than a day old. You may add it to cron to automate.

find . -name “ruby_sess*” -ctime +1 -exec rm -f \{} \;

sudo: giving previlige to non previliged users

Saturday, February 11th, 2006

On *nix systems, there are certain tasks such as running servers, editing sensitive resource or configuration files that only privileged users can do.

During software development phase, many such tasks need to be repeated often, and the application developer needs to request the system administrator each time. Sudo is a perfect tool for such times. ( atleast that is how I came across it)

The root user can specify users or group, and command which they can execute in the /etc/sudoers file. The non previliged user can then use sudo to run commands as previliged users, without loggin in as one. (without the need to know the previliged user’s password that is). Root users should use visudo to edit the /etc/sudoers file. Visudo parses the file for any syntax error.

An additional benefit of using sudo is that it logs each time a user tries to run a sudo command.

You can read more about sudo here or do a man sudo.