Home » Electronics » WiFi (with WEP security) on Raspberry Pi

WiFi (with WEP security) on Raspberry Pi

The Raspberry Pi Linux distribution I’m using is Adafruit’s Occidentalis.  It supports WiFi out of the box and appears easy to configure.  But as noted by Adafruit, adding peripherals to the RPi may increase the loading on the power supply to your board and this, in turn, may affect the voltage presented to the RPi.

This is clearly the case, even for the tiny  OURlink WiFi (802.11b/g/n) USB Adapter (uses the RTl8192cu chip which is supported by Debian Linux) I purchased from Adafruit.  When I plugged it into the RPi, it became unstable and crashed.  Adafruit advises that you can over come this by attach the RPi’s USB port to a powered hub.  (Note that all USB hubs aren’t powered or powered sufficient, and therefore, not all are  recommended.  I used a Dynex 4 Port Hub with a 5V 2.1A power adapter and all seem fine.)  If you find using a using a USB hub completely unacceptable, you could make some RPi board modifications to the polyfuses, but this isn’t the “official/supported” approach for this power problem …. but first …. see the Epilogue below.

My First Attempt (Unsuccessful)

Once I got the RPi USB port properly powered, I followed the Adafruit’s instructions.  I updated the/etc/network/interfaces file with the following:

########## DID NOT WORK FOR ME ##########
# The loopback network interface
auto lo
iface lo inet loopback

# The primary (wired) network interface
iface eth0 inet dhcp

# The wifi (wireless) network interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
     wpa-ssid YOUR_SSID
     wpa-psk YOUR_WEP_KEY

I ran  ifconfig -a and got the following:

This tells me that Linux sees the WiFi device and assigned it device name wlan0. It also says there isn’t an IP address assigned and no data is moving.  Appears that network interface wlan0 isn’t running so I tried bring it up with sudo ifup wlan0 and I got the following:

No IP assigned … now what?

This Worked … But

After the typical thrashing about, it came to me that I’m not using WAP security (which is implied by the/etc/network/interfaces file content) but I’m using WEP.  I did some web searching and found a site that claimed to address Debian WiFi WEP configuration.  This provided me the needed command syntax for the solution.   I updated the/etc/network/interfaces file with the following:

# The loopback network interface<
auto lo
iface lo inet loopback

# The primary (wired) network interface
iface eth0 inet dhcp

# The wifi (wireless) network interface
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
       wireless-essid YOUR_SSID
       wireless-key YOUR_WEP_KEY

I then ran sudo ifup wlan0 to start the wireless networking (Note: you can use sudo ifdown wlan0 to turn-off the wireless network).  This time DHCP discovery appeared to work.  I then ran ifconfig -a giving me the display below with an assigned wireless IP.

The wireless device now has an IP address and data seems to be flowing.  In an effort to further convince myself that the WiFi was working, I disconnected the wired ethernet connection and attempted to re-login in via ssh -X pi@RedRPi.local, over the wireless interface. This failed, giving the message:

ssh: Could not resolve hostname RedRPi.local: hostname nor servname provided, or not known

Working For Sure

I suspected (after more thrashing about) it was Ssh or Avahi/Bonjour or both that was getting in the way.  So I did the following:

    1. I cleaned out the ~/.ssh/known_hosts file on the PC from which I’m accessing the RPi (I’m using Cygwin with Openssh). With the entries in the file removed  ssh keys would need to be recreated on next login.
    2. I then logged into the RPi in via ssh -X pi@RedRPi.local. The login created an entry the ~/.ssh/known_hosts file on the PC.
    3. Using vi, I edited the  ~/.ssh/known_hosts file.  I duplicated the one existing record but changed the  IP address to the wireless address.
    4. I restarted the openssh on the PC.  (I terminated all the Cygwin window and restarted them.  I could get anything else to work short of a PC reboot).
    5. I then logged in using ssh -X pi@ Now I’m wireless!!

My ~/.ssh/known_hosts file looks like this:


I have found that if  I don’t use a USB  powered hub and I plug in the OURlink WiFi (802.11b/g/n) USB Adapter while the RPi is up and running, the RPi will crash.  The good news is that, once the RPi reboots, it runs fine without the powered hub.

So, go ahead and use the WiFi USB Adapter, without the powered hub, but make sure the adapter is plugged in when you boot up …. problem solved!


  1. yustas says:

    ” This time DHCP discovery appeared to work”
    hm… my wifi adapter didn’t work after insert this code
    “auto wlan0
    10 allow-hotplug wlan0
    11 iface wlan0 inet dhcp
    12 wireless-essid YOUR_SSID
    13 wireless-key YOUR_WEP_KEY”
    in /etc/network/interfaces
    but when ethernet is connected hi is work.
    i dont need wifi and ethernet together.
    i need only wifi.
    what will do next?

  2. JPC says:

    Maybe remove line numbers from the code you’ve copy/paste :).

  3. yustas says:

    very funny. decided. lacked power USB

  4. Raslow Powell says:

    Thanks for posting valuable info! I have the same USB wireless adapter and this post will probably save me a alot of swearing later when I have time to set it up! 😉


  5. I’m not sure exactly why but this blog is loading very slow for me. Is anyone else having this issue or is it a problem on my end? I’ll check back later on and
    see if the problem still exists.

  6. I’m so happy to have found your blog, Jeff. Thanks to you, my Raspberry Pi has gone wireless! I look forward to reading the rest of your posts with happy anticipation

  7. memoryleach says:

    I tip my hat (elegantly) to you, Sir!
    Been running my RPi for a year using a wired internet connection. Switching to a wifi dongle I ran into the WEP-related hurdles when trying to connect using Raspbian’s simple WiFi Config tool. Your config file solved those problems at once!

  8. a says:

    Thanks for your tutorial, helped me a lot!

  9. Carlos Luna says:

    Hey Jeff.
    Just want to say thanks a million for the step-through. It was really valuable to go through the steps the way you did. Though in the end my problem was a mistyped password, I would have given up before checking something as silly as that if I hadn’t come across your blog.
    By the way, never say die! After finding my password issue, it still wouldn’t connect to the Wi-Fi. However, upon rebooting, it connected then!

    Thanks again.

  10. habolanos says:

    Hola Jeff,

    Tu explicación es muy clara, de verdad que me sirvió mucho para salir de apuros, pues en casi toda la red se hace referencia a wifi tipo WAP y no a WEP.

    De antemano muchas gracias.

  11. ayushpateria says:

    Thanks Jeff! You made my WiFi connection work.

  12. Time2getRaspberry says:

    Thanks so much! My raspberry is now working wireless with a netgear N150 key.

  13. Stenopus says:

    In interfaces put wireless-key s:YOUR_WEP_KEY instead wireless-key YOUR_WEP_KEY.

  14. Ian says:

    Thanks for this, it helped me get my Raspberry PI configured on a WEP network.
    NOTE: I had to put the wireless-key in quotes. i.e. like this:

    wireless-key “4565AB…. ”

    BUT the wireless-essid must NOT be in quotes. i.e.

    wireless-essid mynetworkname

  15. Keep up the great work and bringing in the group!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: