1

I've got my Pi connected to my router using a regular Ethernet cable and I can SSH into the Pi. That works pretty well, but I now want to connect my Pi to the Wi-Fi so I don't need an Ethernet cable anymore.

So following these instructions I created a file /etc/wpa_supplicant.conf and pasted in the following:

network={
    ssid="ssid_name"
    psk="password"
}

I then did the following:

pi@raspberrypi:~$ sudo wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
Successfully initialized wpa_supplicant
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
pi@raspberrypi:~$
pi@raspberrypi:~$ sudo dhclient wlan0
Restarting ntp (via systemctl): ntp.service.
pi@raspberrypi:~$

I don't really know what this output means so I just disconnected the cable to see what would happen. Unfortunately my SSH session got cut off, and in the UI of my router I don't see the Pi appearing as a Wi-Fi connected device.

So from here I'm kinda lost. Seeing that I don't even know if it is possible to connect to a router using both Wi-Fi and an Ethernet cable, I'm not sure if it is possible at all to connect it to the Wi-Fi from an SSH session.

If that is not possible, I guess the only option is to get a screen and a keyboard for my Pi, right?

All tips are welcome!

2
  • Where it says ssid="ssid_name" in the quotation marks you should have put in your router's ssid. And where it says psk="password" you should have put your router's password into the quotation marks. Then you can SSH in as normal using the IP address of your Pi.
    – Darth Vader
    Commented Mar 5, 2017 at 17:24
  • Those "instructions", from 2012, are OBSOLETE See /etc/network/interfaces
    – Milliways
    Commented Mar 5, 2017 at 22:04

1 Answer 1

2

What about the file /etc/network/interfaces ?

Is the interface wlan0 even listed in it and with what kinds of options ?

Something like this should do the trick:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf
iface default inet dhcp

In this example wlan0 is set to DHCP, therefore the IP address will be assigned by the router and could change over time. If you want you can use a static address, that you know is outside the DHCP range (check your router for this).

Check the output of ifconfig to see if wlan0 is up and already has an IP address assigned perhaps.

2
  • Awesome! I replaced the lines that were in /etc/network/interfaces for wlan0 with your four lines, rebooted while simultaneously disconnecting the ethernet cable and BOOM!! it showed up in the UI of my router with a new ip. Thanks a million, you made my day!
    – kramer65
    Commented Mar 5, 2017 at 17:14
  • The /etc/network/interfaces above contains errors, but the programs are very forgiving, so it may work. Better to do it properly; see How do I set up networking/WiFi/Static IP
    – Milliways
    Commented Mar 5, 2017 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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