Connecting to wifi with specified wep key index

Posted by Dan Sosedoff on March 09, 2009

Since i got trouble while connecting to wireless network with given parameters in linux, i tried a lot of ways to get my internet working.

So, the problem is: Windows Network manager have special option – Key index. The index is transmitted with the encrypted message. The receiver then looks-up the key corresponding to the transmitted index and uses it to decrypt the message. But linux (ubuntu) network managers i`ve tried have no key index field, so there is no way to set it up properly with gui. Connection won`t work if index value set to incorrect value.

After giving up to find any useful gui program i wrote small shell script only for one network (because i have no access to router and no chance to improve some security settings):

#!/bin/bash
 
# settings
interface="ath0" # wireless interface, default to wlan0
essid="NETWORK_NAME_HERE"
key="YOUR_KEY_HERE"
index="4" # can be [1..4]
 
# check permission
if [ "$(id -u)" != "0" ]; then
   echo "Run this script under root" 1>&2
   exit 1
fi
 
# show information
echo "Settings:"
echo "-> Interface: $interface"
echo "-> Wifi ESSID: $essid"
echo "-> Key: $key"
echo "-> Key Index: $index"
 
# perform association
ifconfig $interface down
iwconfig $interface essid $essid
iwconfig $interface key $key [$index]
iwconfig $interface key [$index]
ifconfig $interface up
dhclient $interface

Download shell script – http://files.sosedoff.com/9591756c/

HDD click problem in Ubuntu

Posted by Dan Sosedoff on January 30, 2009

Since i completely switched to ubuntu 8.04 on my laptop i got very weird “click” sounds from hard drive. I thought it was just a simple “sleep” mode, parking heads or something pretty simple. But that sound began to appear so often (sometimes 2 clicks in 1 secons)  that i cant even get sleep with that disturbing sound.. But that sound appeared only in ubuntu and never heard it in other os. Wtf  is going on? After googling for a short time i figured out what was the problem – Advanced Power Management in Ubuntu.

Solution was very simple. Just turn off this power management:

sudo hdparm -B255 /dev/sda

If you have more than one drive – the same operation but with different device. That`s it.

Configuring WebDAV Server

Posted by Dan Sosedoff on January 15, 2009

Some time ago i had reason to make couple servers being accessible by WebDAV protocol.
But all our special storage servers were running nginx 0.6.x, that also supports this protocol.
By the way, it doesn`t support meta commands such as PROPFIND, OPTIONS, so if you try to connect to server with some command-line or GUI client it will close connection due to accepting “unknown” commands, but will work only with PUT, DELETE, COPY, MOVE, MKCOL requests.
It was a huge problem, because for a long time i couldn`t figure out what the reason of reject. Server allways respond with ‘405 Not allowed’. But when i tried put file – it worked.
Also, alternate fast server Lighttpd supports all meta commands.

Simple nginx configuration:

server {
    listen 80;
    server_name localhost;
    access_log log/access.log;
    error_log log/error.log;
    charset utf-8;
    client_body_temp_path client_body_temp;
    autoindex on;
 
     location / {
          root /home/dav/public;
          dav_methods PUT DELETE MKCOL COPY MOVE;
          dav_access user:rw group:rw all:r;
          create_full_put_path on;
 
          # auth access
          auth_basic "Restricted";
          auth_basic_user_file ;
     }
}

After configuring server, you`ll need to create htpassword file, that will keep user credentials.
Simple example:

htpasswd -c /where/to/save/the/file username

More information about how to configure nginx can be found at http://wiki.codemongers.com/NginxModules

Streaming FLV videos problem in nginx 0.6.32

Posted by Dan Sosedoff on January 15, 2009

nginx, fast small webserver, supports flash flv files streaming.
I am currently using JW Player 4.0 on projects, its free, lightweight and have a lot useful features.
But, i got some problems with its latest versions. It always adding some special information, like player container resolution like this:

myvideo.flv?start=2659763&width=280&version=4.0&...

Result: cannot seek on the video.
Found a solution on ruby forum. http://www.ruby-forum.com/attachment/2307/patch.flv
You need only apply this patch to sources and rebuild nginx. That`s it.

P.S. Don`t know about older versions of nginx, but 0.6.32 from sources doesnt work with JW Player 4.0.