Prevent Indexes to be listed

A lot of times, when you have a web server, you need to prevent Indexes to be
shown.

I ran into that problem the other day and although some Virtual Hosts accepted
the following for not showing indexes, others wouldn’t:

<Directory /path/to/web>
Options -Indexes
</Directory>

This approach would remove the ability to have Indexes shown accross all your
Virtual Hosts, with code:

sudo a2dismod autoindex
sudo apache2ctl graceful

The first command just disables the module and the second restarts Apache in a
graceful mode (will keep connections alive).

October 27, 2008   No Comments

Configuring SNMP

A while ago I tried to set Zenoss to monitor several diferent servers (Windows
included) and found everything went great with CentOS and Windows but not quite
right with Ubuntu.

I decided to give it a try one more time and found that although I was doing
everything correctly, Ubuntu has a “/etc/default/snmp” file that has some
configuration properties that needed to be changed as well.

I created a small script (you can download it from here) to automate a little
bit the process. If you don’t want to run the script, here is a list of things
you need to do to have a “Read Only” SNMP configuration in Ubuntu:

Install SNMP:
sudo apt-get install snmp snmpd

Backup the default config:
sudo mv /etc/snmp/snmp.conf /etc/snmp/old.snmp.conf

Create the new config:
sudo echo “rocommunity public” > /etc/snmp/snmpd.conf

Modify the line in /etc/default/snmpd:
sed -i ’s/127.0.0.1//g’ /etc/default/snmpd

Restart SNMP agent:
sudo /etc/init.d/snmpd restart

If you want to test the configuration works, try this command:
snmpwalk localhost -v1 -c public system

October 20, 2008   No Comments

Python for SysAdmins Virtual Server

Introduction:

Python for Unix and Linux System Administrators is a book written by Noah Gift and Jeremy Jones that comes with a complimentary Virtual Machine. The idea is to be able to run the Virtual Machine with NO EXTRA CONFIGURATION and have everything needed running and working. If you are running VMWare Server 1.0.5 or later you *should* have no problems running the VM once this is decompressed.

VMWare Image Specifications:

  • Ubuntu 7.10 Server Version (no X or GUI installed)
  • Compressed in tar.gz format is 548 MB total (4GB decompressed).
  • Created with VMWare version 1.0.5
  • 2 x 2gb hard drives.
  • 512MB of RAM
  • 1st hard drive mounted in “/”
  • 2nd hard drive mounted in “/usr”
  • VMWare tools installed

Main packages and configurations:

  • Trac and Subversion integrated together and served via Apache including all the code.
  • Fully working SAMBA and LDAP configuration as a Primary Domain Controller.
  • Apache authenticates user(s) to LDAP.

Instructions:

  1. Download the latest version of the VM by doing:
    wget http://examples.oreilly.com/9780596515829/vm/
  2. Untar the file: tar xzvf py4sa.tar.gz
  3. You need VMWare Server installed (version 1.0.5 or higher). Open it and go to File -> Open
  4. Browse where the uncompressed image is and select the “py4sa.vmx” file.
  5. Select the image in the main screen and hit the PLAY button. IMPORTANT! Hit “keep” or “I have copied this image” when prompted the first time you run the image.
  6. Check the “Important Notes” for a couple of bugs related to the login prompt.
  7. All login/password credentials are:
    user: py4sa
    password: py4sa
  8. The image will load Apache2, SAMBA, LDAP, Subversion and Trac by default, so you should have everything running from the get-go.
  9. Run “ifconfig” to see the IP address the image has and type the same IP into your browser to see “Python For SysAdmins” as a listed project for Trac.

Important Notes:

  • This Ubuntu Server Version seems to have a bug where it will show you the login prompt before finishing the complete loading of all the services.
  • It will hang at the line where it tries to run the rc.local scripts. You need to hit “enter” to get the login prompt again.
  • There is a changelog in “/root/changelog” that has some information on the work done to the VM.

Some links:

August 30, 2008   No Comments

Move your svn repo with “switch” and “relocate”

Sometimes repositories move, or they simple change a url and then you are left with a checked out version that no longer can do updated.

Subversion ships with a “switch” tool that accepts a “relocate” input.

The correct usage is:

svn switch
- -relocate http://old.url.com/trunk http://new.url.com/trunk/

You have to be really careful and double check the url’s or else you will be left with a broken repository.

August 22, 2008   No Comments

Return home directory in Python

I had previously used something like( which works OK):

commands.getstatusoutput(’echo $HOME/’)

But I think this is much better…

os.environ.get(’HOME’)

August 13, 2008   No Comments

Show content from another server (Apache2)

Somehow, if you have 2 servers or sites and need to include on of them within the other without doing any copying of files or moving stuff around, there is a simple way to do this with the proxy module in Apache.

To enable mod_proxy you can do:

sudo a2enmod proxy

sudo /etc/init.d/apache2 reload

After this, remember that this module will break your inbound connections if you don’t change this part of /etc/apache2/mods-enable/proxy.conf:

Deny  from All

To:

Allow from All

Another Apache reload an you should be good to go.

Now get to the Virtual Host file and add this after “ServerName” and before any “<Directory>” or “<Location>”

ProxyPass                  /newfolder     http://other-server.com/
ProxyPassReverse     /newfolder     http://other-server.com/

Another Apache reload and you will correctly have the content of other-server.com in the non-existent “newfolder”.

July 6, 2008   2 Comments

Install Vmware on Ubuntu Server

This is a problem, since a server doesn’t come with all the libraries Vmware needs to run.

It took me a while to get those since the vmware-config.pl script is not to explicit as to what is missing.

If you get these installed you should be good to go to complete the vmware install:

sudo apt-get install libx11-6 libx11-dev libxtst6 libxrender1 libxt6 zlib1g

July 3, 2008   No Comments

Playing with Fluxbox

I have started to use Fluxbox on my personal laptop. I like it so much that I will soon make the change for my work computer (yes, I am allowed to use Ubuntu at work).

Fluxbox is a extremely light desktop environment for Linux and I found it by chance when using ophcrack live cd at work to solve a problem trying to crack a windows password from an old computer.

You can try it without messing anything on your Gnome or Kde setup. Just do:

sudo apt-get install fluxbox

Then logout and select “Fluxbox” as your session before you login.

This file is my (ongoing) effort to start customizing shortcuts.

Just a note to new users: the menu is found by right clicking on an empty space on your desktop.

June 29, 2008   No Comments

disable system-beep

The easy way to do this with the desktop environment is easy. But this is the way to do it at the command line.

At the end this way is better since you will be able to do it no matter what desktop environment you have. System Beeps are annoing anyways, right?

So open and edit the blacklist file:

sudo vim /etc/modprobe.d/blacklist

Add this line:

blacklist pcspkr

The remove the module:

modprobe -r pcspkr

Nothing of this is permanent though so you can revert back just enabling the module and commenting out the line in the blacklist file.

June 29, 2008   No Comments

Install mod_proxy

Had some issues the other day trying to get mod_proxy to work.

It seems it doesn’t come with the default modules in Apache so I had to go and get it (beware! before installing keep in mind it restarts apache once its done!):

sudo apt-get install libapache2-mod-proxy-html

This is kind of weird naming convention for that module, it took me a while to find it. After placing the correct rules in the VirtualHost I was getting access denied.

This is because mod_proxy has a configuration file in /etc/apache2/mods-enabled called proxy.conf that comes with a security rule of:

“Deny All”

You will have to edit this (I changed it to Allow All since I wanted all traffic available) according to your specific situation.

One final reload of Apache and everything was working again:

sudo /etc/init.d/apache2 reload

June 5, 2008   No Comments