Auto connect to any open WiFi with Debian

Solution 1:

You can do this in BASH. Simply check your connection every minute or ping response(if its too high). Scan networks, and switch it.

for scanning you can use:
$ iwlist wlan0 scan

for connecting you can use

#!/bin/bash
killall -9 dhclient
ifconfig wlan0 down
ifconfig wlan0 up
iwconfig wlan0 channel CHAN
iwconfig wlan0 essid ESSID
ifconfig wlan0 up
dhclient wlan0

you can easily bind(combine) the scanning script to(with) the connecting one using grep/awk/cut which are very helpful tools.

If you are using Ubuntu(Spying!!!) turn off network-manager service by:
temp solution till reboot
$ /etc/init.d/network-manager stop
permament solution till chmod +x (when you want networkmanager back)
$ chmod -x /etc/init.d/network-manager

on Fedora(You are safe for now!) the service is called NetworkManager:
temp sol:
$ service NetworkManager stop
perm sol:
$ service NetworkManager disable