Connect to Wireless Network at Startup

Assuming WPA/WPA2 security is used, first thing to do is to get a hash/hex of the password. Below “myssid” is the wireless network’s SSID, and “mypassword” is the password for this network.

Step 1 Generate a WPA password hash to be used later when setting up network interfaces:

$ wpa_passphrase myssid
# reading passphrase from stdin
mypassword
network={
	ssid="myssid"
	#psk="mypassword"
	psk=2f0568b3492812bd56b946dbaf3fd7dd669b9a4602a09aa6462ff057949b025c
}

Step 2 Configure a wireless network interface using the password hash from Step 1:

$ vi /etc/network/interfaces
   auto wlan0
 
   # configuring a static IP
 
   iface wlan0 inet static
   address 192.168.0.34
   gateway 192.168.0.1
   network  192.168.0.0
   broadcast 192.168.0.255
   netmask 255.255.255.0
 
   #  OR if static IP is not needed ignore above 6 lines and uncomment the one below
   #  iface wlan0 inet dhcp   
 
   # configure WPA/WPA2 security
   wpa-ssid myssid
   wpa-psk 2f0568b3492812bd56b946dbaf3fd7dd669b9a4602a09aa6462ff057949b025c

Tags: