I am trying with:

$ sudo iwconfig wlan0 essid mynetwork key 4bare2011

$ sudo iwconfig wlan0 essid mynetwork key 4bare2011 mode Managed

and similar combinations. I'm using Ubuntu 14.04.

The key is right and works for other clients. But it doesn't get accepted. s:4bare2011 is also getting an error message. ddddddddd is accepted (but is wrong). It looks like the system only accepts hex, but converting the key above to hex also didn't help.

How can I connect, without changing the key?

2 Answers 2


An alternative to using iwconfig and wpasupplicant "by hand" is to edit /etc/network/interfaces and add a stanza like

iface wlan0 inet static
    address 192.168.x.x
    gateway 192.168.x.1
    dns-nameservers 192.168.x.1
    wpa-ssid mynetwork
    wpa-psk  4bare2011


iface wlan0 inet dhcp
    wpa-ssid mynetwork
    wpa-psk  4bare2011

You can then connect with

ifup wlan0

and disconnect with

ifdown wlan0

This still uses wpasupplicant but it's transparent to you.

For more information on the different fields you can use, read interfaces(5)

This alternative also opens up all sorts of interesting possibilities using interface mapping

  • Still, this works when I set the router to wpa, but Ubuntu seems to have a problem when it comes down to connect to wpa2. Nov 15, 2014 at 18:05

Your wifi network most likely uses WPA authentication, not the obsolete and insecure WEP. For WPA (WPA2, etc...), you cannot set the key directly using iwconfig because there is a higher level protocol that must be observed. For WPA, you need to run the wpasupplicant software.

Most operating system distributions provide a supported method for correctly starting wpasupplicant so that most end users don't need to worry about it manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.