WPA without NetworkManager or alike
$ sudo chmod 0600 /etc/network/interfaces $ sudo wpa_passphrase myssid my_very_secret_passphrase
The output will be similar to this:
network={ ssid="myssid" #psk="my_very_secret_passphrase" psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b }
Configure /etc/network/interfaces:
iface wlan0 inet dhcp wpa-ssid myssid wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b