How to use ftp in a shell script


Sometimes I want to FTP a file from one machine to another. Usually, I can do the transfer interactively, but every so often, I would like to have a shell script do the file transfer. This task has eluded me in the past, but I finally figured it out. I've not seen this particular trick documented in the past, so I submit it for your approval...

Install python-2.7 and fabric on CentOS-5.6

Install the required packages first:

# yum install gcc gcc-c++.x86_64 compat-gcc-34-c++.x86_64 openssl-devel.x86_64 zlib*.x86_64

Download and install python-2.7 from source:

$ wget
$ tar -xvzf Python-2.7.2.tgz
$ cd Python-2.7.2
$ ./configure --with-threads --enable-shared
$ make
# make install

Link the shared library:

# echo "/usr/local/lib" >>/etc/
# ldconfig

Verify with:

$ which python
$ python -V

Install easy_install:

$ wget
# python

Install fabric via easy_install:

easy_install fabric

To get the location of site-packages for current version of python:

$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

GPG Quick Start


A quick gpg HOWTO for getting started with GnuPG.

Delete trac tickets

To delete trac tickets without installing extra plugins, here's the SQL.

Note: make sure to create a backup of trac.db first.

$ sqlite3 trac.db
delete from ticket_change where ticket = <TicketID>;
delete from ticket_custom where ticket = <TicketID>;
delete from ticket where id = <TicketID>;

Replace "TicketID" with the ID of ticket that needs to be deleted.

To purge out all tickets, use the same sql without the where clause.



This modified rblsmtpd features parameter-enabled syslog-based RBL server and source-IP logging.

Review the FAQ for the compile, install and testing...

auotmount shares for vzyum updates

Note: The directions at "" did not quite work for me as ".gpgkeyschecked.yum" gets created in the yum-cache directory as well and is not available to the containers. The workaround below worked for me.

To share the vzyum cache directory between various containers. Edit "/etc/auto.master" to include the following:

/vz/root/{vpsid}/var/cache/yum-cache /etc/auto.vzyum

Include one line for each installed or planned VPS, replacing {vpsid} with the adequate value.

Then, create "/etc/auto.vzyum" file with only this line:

share -bind,ro,nosuid,nodev :/var/cache/yum-cache/share

Restart the automounter daemon.

Edit "/vz/template/centos/5/x86_64/config/yum.conf" and change cachedir location:


Create the corresponding cachedir:

mkdir /var/cache/yum-cache/share

Test with:

vzyum {vpsid} clean all

This should create all of the yum cache directory at "/var/cache/yum-cache/share" location and should be available to the openvz container via bind mount.

chroot ftp user outside plesk

To chroot ftp user outside of plesk, add the user belonging to psacln group.

usemod -g psacln <username>

DirectAdmin user and password

I've had to test some connectivity issues with pop and imap clients without having access to their account info.

"/etc/virtual/{domain.tld}/passwd" file holds their user and md5 password hash. Make sure to backup this file first.

Generate a new md5-based password hash:

openssl passwd -1

Edit "/etc/virtual/{domain.tld}/passwd" file replacing the password hash with the above.

Test login to mail.

Once debugging is finished, restore the file back.

The Guide to IP Layer Network Administration with Linux


The Guide to IP Layer Network Administration with Linux was conceived as a project to document and provide examples for the use of Linux-specific IP networking tools.

The book includes coverage of the following topics: network address translation (NAT), address resolution protocol (ARP), routing, and masquerading. There is a nascent section on bridging, although the focus of the documentation is the use of layer 3 Linux technologies.

Check bots success POSTs in apache access log

Here is a one liner to check for IPs of bots that are misusing your site.

$ awk '$6 ~ /POST/ && $9 ~ /200/ {print $1 " " $7}' /var/log/httpd/access_log | sort | uniq -c | sort -n | tail

This will give you the top 10 IPs and URIs with a hit count.

Consider blocking those rogue IPs with a high hit count via iptables.

Syndicate content