在 /etc/wpa_supplicant/wpa_supplicant.conf
加入 network 設定
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="Example"
psk="password"
id_str="office"
}
network={
key_mgmt=NONE
}
# 可以參考 /usr/share/doc/wpasupplicant/examples/wpa-roam.conf
然後在 /etc/network/interfaces
加加 mapping
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface office inet dhcp
之後開機就會自動 connect 到合適的 AP 了