My digital playground

Try 2.5GB online backup from Mozy today, for free!

Filed under: Uncategorized — Andre @ 15:38 January 23rd, 2010

A friend of mine told me about a online backup service that gives you 2 GB online storage for free, and an additional 512 MB if you use an referer link.

After testing this for a day now I am very pleased with all the configuration options and that the service offers 448 bits blowfish encryption, or you could use your own key and get 256 bits AES encryption on all your files.

It was as simple as installing the backup client, and configure what files it should sync and how often. The rest is done by Mozy.

To get more free storage you get an referer link, wich will give not only you, but also your friend 512 MB extra storage each. To sign up now and get 512 MB extra storage yourself click on my referer link: https://mozy.com/?ref=XP5WY5.

It’s worth a try!

  • Click on the link to visit Mozy’s website.
  • Navigate to Products –> MozyHome on the top menu.
  • On the next page click Try It Free or under 2GB of 100% free backup space
  • Click on Sign Up Now under MozyHome Free
  • Enter your credentials and your ready to enjoy safe automated online backup. With 2.5 GB totally free of charge!

Enjoy, and thank you for using my referer link! =)

Basic configuration of Cisco IOS with SSH from scratch

Filed under: Uncategorized — Andre @ 11:37 November 18th, 2009

Here is my _very_ basic configuration of a Cisco router running IOS. Just remember to change all {VARIABLE} to the correct value including the {} part.

This will result in an all basic configured router, running SSH and with a user you can use to log in through SSH.

Router> enable

Router# configure terminal

Router(config)# hostname {ROUTER_NAME}

Router(config)# enable secret 0 {ENABLE_PASSWORD}

Router(config)# interface fastEthernet 0/0

Router(config-if)# ip address {IP_ADDRESS} {SUBNET_MASK}

Router(config-if)# full-duplex

Router(config-if)# speed 100

Router(config-if)# no shutdown

Router(config-if)# exit

Router(config)# username {USERNAME} privilege {PRIVILEGE_LEVEL} secret 0 {USER_PASSWORD}

Router(config)# ip domain name {DOMAIN_NAME}

Router(config)# crypto key generate rsa
How many bits in the modulus [512]: 2048

Router(config)# line vty 0 4

Router(config-line)# login local

Router(config-line)# transport input ssh

Router(config-line)# exit

Router(config)# ip routing

Router(config)# exit

Router# show running-config

Router# copy running-config startup-config
Destination filename [startup-config]? [PRESS_ENTER]

Router# exit

Creating a “bash alias” with an argument

Filed under: Uncategorized — Andre @ 14:41 September 16th, 2009

While setting up and testing the anti virus/spam filter of a mail server I usually send a lot of “test spam” to myself and that involves a pretty long line that needs to be typed in every time, and changed for every mail account i test. I want to make an alias for this using an argument containing the email address, but bash makes it hard if not impossible to do so with an alias. Fortunately it allows you to create an function instead.

The command for sending a “GTUBE” test spam message is

sendmail john@example.com < /usr/share/doc/spamassassin/examples/sample-spam.txt

To make this easier I wanted to make an alias for it, so I can type sendspam <email -address> to send it. And as I mentioned earlier bash don’t allow you to use arguments in aliases. But making a function is just as easy. Add the following line in ~/.bashrc

sendspam () { sendmail "$1"  < /usr/share/doc/spamassassin/examples/sample-spam.txt; }

After the next login you will now be able to use the following command to send a test spam message

sendspam john@example.com

Check MD5 sums for all files in folder with one command

Filed under: Uncategorized — Andre @ 15:01 September 6th, 2009

I came over a simple but genius one-liner for the Linux shell to check the MD5 sum of all files in a folder. It will create a file.md5 containing the checksum just like on the FTP servers.

for c in ./*; do md5sum $c > $c.md5; done

and to list all files with the checksum just use

cat *.md5

PHP: Check if string contains a value in array

Filed under: Uncategorized — Andre @ 18:56 August 27th, 2009

I was writing a a very simple script to check if a visitor was a bot. Therefore I made an array of words used by bots, and soon found out that PHP got a function to check a string in an array, but not an array in a string. So I wrote a simple function, maybe someone else needs it?

// PHP Function to check if any value in an array is in a string
//
function isin_string($string, $array) {
        foreach ($array as $value) {
                if (!stristr($string, $value) === FALSE) {
                        // value is found
                        return true;
                } else {
                        // value not found
                        return false;
                }
        }
}

Or in a simpler way just implode() the array and use strrpos()

function string_in_array($string, $array) {
    $array = implode(" ", $array);
    if strrpos($array, $string) {
        // String is found
        return true;
    } else {
        // String was NOT found
        return false;
    }
}

Automatically remove deleted e-mails after 14 days

Filed under: Uncategorized — Andre @ 20:47 August 9th, 2009

I have a email server using IMAP, and as you probably know you can mark a mail as deleted but it will still be on the server occupying space. There are usually a option to purge them, but most users doesn’t care..

To solve this problem, I will notify all my users that mails will automatically be deleted after 14 days, and set up a cron job for the task.

To find and delete the mails I’ll use the following command

find /var/vmail/ -name '*,ST' -ctime +14 | xargs rm -f

Using crontab -e I will make it run every day at 15:00. So this is how my crontab looks after adding the line

# m h  dom mon dow   command
0 15 * * * find /var/vmail/ -name '*,ST' -ctime +14 | xargs rm -f

Using keyfiles to log in with SSH in steps

Filed under: Uncategorized — Andre @ 04:11 August 3rd, 2009

If you have one or more servers you log in to very often like my self, you might get a bit bored of typing the same passwords when connecting through SSH. The solution is really simple, and as an bonus it’s even more secure than regular login. The following steps assumes you are using Linux.

  1. On you workstation you will have to make a directory and generate a key pair. (This is only needed once, you can use the same key on more servers)

    mkdir ~/.ssh
    ssh-keygen -t rsa

    This will create two files in your .ssh folder named id_rsa and id_rsa.pub. The last one is the public file and is what we are going to store on the server.

    The other file is your private key. Never show, give away or keep this file on a public computer.

  2. Copy the public file id_rsa.pub to the server using scp (secure copy).

    scp .ssh/id_rsa.pub user@domain.tld:/home/user/
  3. Then we log in to the server and setup everything with the right permissions.

    ssh user@domain.tld
  4. Create a .ssh directory if it doesn’t exist. And copy the content of the public key file into the authorized_keys. And delete the uploaded public file. The reason I copy the content and not the file itself is because you may have other keys stored in there.

    mkdir -p ~/.ssh
    cat id_rsa.pub >> ~/.ssh/authorized_keys
    rm id_rsa.pub

    And set the right permissions on the file and folder. (Remember to change user:user to reflect your username!)

    chown -R user:user ~/.ssh
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
  5. Now logout from the server using exitand try logging in again ;-)

And remember that the file id_rsa is your private key. Never show, give away or keep this file on a public computer. I cannot stress this enough!

WP plugin Download Monitor rewrite rule for nginx

Filed under: Uncategorized — Andre @ 10:14 August 1st, 2009

I just wanted to post a simple rewrite rule for all the people that is using the WordPress plugin Download Monitor on Nginx.

# Download folder rewrite
#
location /downloads/ {
    rewrite ^/downloads/(.*)$ /wp-content/plugins/download-monitor/download.php?id=$1 last;
}

The code assumes you have set the “Custom download URL” to downloads in the plugin configuration.

Set up a temporary TFTP server on Linux

Filed under: Uncategorized — Tags: , , , — Andre @ 07:45 July 29th, 2009

Yesterday when I was going to flash a router I needed a TFTP server, and as I like my system as it is I don’t want to install a TFTP server just to uninstall it again since I’m only using it for half an hour.

So I went searching for an TFTP server that didn’t require installation and was easy to configure, a Linux counterpart for tftpd32 for Windows. What I found was the Open TFTP Server wich also comes with an precompiled binary for Linux/Intel. It was also a dream to configure.

  1. First we open up a terminal

  2. Then we download the tftp server

    wget http://downloads.sourceforge.net/project/tftp-server/tftp%20server%20Unix/Unix%20Stable%201.6/tftpserverspV1.62.tar.gz
  3. Then we extract it and enter the directory and create a new tftp root folder

    tar xvfz tftpserverspV1.62.tar.gz
    cd tftpserversp
    mkdir tftproot
  4. Create a new file called config.ini, and inside it we put the following. Just remember to change the <USERNAME> to your username.

    # Set the home directory where all files are stored
    [HOME]
    /home/<USERNAME>/tftpserversp/tftproot
    # Set the username that the process will run under
    [TFTP-OPTIONS]
    username=<USERNAME>

    Look at the tftpserver.ini that came with the server for more configuration options and explanation.

  5. Now were ready to run the server, and we use the following command

    sudo ./tftpserver -v -i config.ini

    The -v parameter makes it run in Verbatim mode and not as a daemon, and the -i specifies the config.ini file we just created.

Now you just put all the files you want available in the /home/<USERNAME>/tftpserversp/tftproot/ folder and grab them through TFTP.

nginx, php, upload and error 413: entity too large

Filed under: Uncategorized — Tags: , , , , — Andre @ 17:04 July 27th, 2009

The other day I was setting up a mail server and webmail for the users. I chose Nginx for task of course, and after installing everything and setting up Squirrelmail I took it for a test drive.413-entity-too-large

I had already configured PHP to allow 64 MB uploads for the webmail users, and everything looked nice.. That was until I tried sending a mail with a 1.8 MB attachment.

After a little uploading the screen went blank and only displayed a 413 – Entity too large error message.

What too large?? 1.8 MB it’s not even 2 MB’s and I get an error, when it’s supposed to accept up to 64 MB uploads..

After some searching and questioning it came for an day that Nginx has a parameter called client_max_body_size that by default is set to 1 MB, way less than 64 MB that I wanted.

To fix that you have to open the file /etc/nginx/nginx.conf in nano or whatever and add the following between the http { … }

client_max_body_size 64m;

Please note that the value is 64m and not 64mb.

Then all you need is a restart of the nginx service

/etc/init.d/nginx restart
Older Posts »