22

I bought the new Raspberry Pi W but I don't have right now an mini-HDMI adaptor (to connect it to a monitor) neither an Ethernet module to connect by SSH.

Can I connect somehow by SSH through USB?

How can I connect by SSH by WiFi without it being setup? Will the WiFi automatically connect e.g to a wireless network without password?

Jacobm001
  • 11,898
  • 7
  • 46
  • 56
Mikel
  • 323
  • 1
  • 2
  • 4

8 Answers8

22

That's a tough one. The WiFi won't automatically connect. So I would try the following:

  1. Image a micro SD card with the Raspbian OS image using Win32DiskImager.

  2. Manually configure your WiFi from another computer. In another computer running Linux (or PC with Live CD) you could edit the following file:

    /etc/wpa_supplicant/wpa_supplicant.conf

And add the following where you enter your WiFi network SSID and password details:

network={
    ssid="SSID"
    psk="password"
    key_mgmt=WPA-PSK
}
  1. Enable SSH on the Pi from another computer. Create a file on the /boot partition named “ssh”.

Put the SD card on your Pi and if everything works as I hope it would, you'll be able to see the Pi on your WiFi network using your router app and SSH into it. Good luck, hope it helps.

recantha
  • 4,489
  • 20
  • 26
Ricardo
  • 1,048
  • 8
  • 7
16

You are looking for information on running "headless". There are details on this on the raspberry pi site. https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=161202

Basically put a file, wpa_supplicant.conf, on the "boot" sector of the sdcard, that you can see from windows, and edit the file to include your wifi credentials:

network={
       ssid="YourNetworkSSID"
       psk="Your Network's Passphrase"
       key_mgmt=WPA-PSK
    }
Will Allen
  • 161
  • 3
8

You can drop in a wpa_supplicant.conf file in the boot directory before installing the SD Card into the Pi. When the Pi boots up, the file /etc/wpa_supplicant/wpa_supplicant.conf will be overwritten (or maybe appended, I'm not sure) with the wpa_supplicant.conf file in the /boot/ directory.

Use the following syntax:

network={
    ssid="YourNetworkSSID-1"
    psk="passwordOne"
}

network={
    ssid="YourNetworkSSID-2"
    psk="passwordTwo"
}

The above setup works for standard WPA wifi connections. There are additional settings in the example below:

network={
        ssid="myssid"
        scan_ssid=1
        psk="incorrect_version_of_mypassword"
        mode=0
        proto=WPA2
        key_mgmt=WPA-PSK
        pairwise=CCMP
        group=CCMP
        auth_alg=OPEN
        id_str="raspi"
        priority=5
}

Make sure to create the wpa_supplicant.conf file in a text editor set to UNIX encoding (if you're doing this from Windows).

  • I'm having issue of ssh and wpa_supplicant.conffiles being removed each time my pi zero w boot. That NIX encoding seems help. To be safe, I added the line ctrl_interface, update_config and country line in conf. – checksum Nov 27 '17 at 10:03
7

You can SSH in from USB after some configuration.

This assumes you're not using NOOBS. Doing this with a NOOBS SD card is a little harder and (to my knowledge) impossible on Windows.

  1. First, the Raspberry Pi Foundation disabled SSH as a security precaution, so you'll have to connect the SD card to a computer and put a file called "ssh" (no extension) in the drive labeled "boot" that pops up. (If you're running Windows, only one drive will show up. That one will work.) Now the Pi will enable SSH on boot.
  2. Edit the file config.txt and add dtoverlay=dwc2 on its own line at the end.
  3. Edit the file cmdline.txt and add modules-load=dwc2,g_ether right after it says rootwait. Seperate it from rootwait with a space. Don't add it on a new line, add it on the same line.

When you put the SD card in the Pi and plug it in to your computer (use the left USB port where the USB connectors are on the bottom), it should show up as an ethernet device. You should be able to SSH to pi@raspberypi.local from the attached computer.

Edit: Ricardo's answer reminded me that you could also just do step 1 then see my answer on this related post.

anonymoose
  • 426
  • 1
  • 4
  • 12
3

You can connect to wifi by creating a wpa_supplicant.conf file in SD Card.

https://www.installvirtual.com/how-to-connect-raspberry-pi-to-wifi-without-a-monitor

You can create an empty ssh file in SD Card to enable ssh while booting.

touch ssh

and insert it in your raspberry pi.

https://www.installvirtual.com/enable-ssh-in-raspberry-pi-without-monitor/

3

Use an awesome app for Mac and maybe windows called PiBakery which is a drag and drop way of setting up Pi zero. That what I did and it really helped. Check it out here: http://www.pibakery.org/

Leo
  • 109
  • 1
  • 1
  • 8
0

If you have windows and don't have access on partition only boot, you can try this • If a wpa_supplicant.conf file is placed into the /boot/ directory, this will be moved to the /etc/wpa_supplicant/ directory the next time the system is booted, overwriting the network settings; this allows a Wifi configuration to be preloaded onto a card from a Windows or other machine that can only see the boot partition.

BoBiTza
  • 1
  • 1
-1

I failed to use the above answers for WPA2.

I used:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid <ssid here>
wpa-psk <psk here>

in the /etc/network/interfaces file.

https://www.raspberrypi.org/forums/viewtopic.php?t=50312 http://blog.darrenparkinson.uk/2013/10/accessing-raspberry-pi-filesystem-from.html

Retiarius
  • 101
  • 1
  • This is not the preferred method of configuring networking on recent versions of Raspbian (jeesie and stretch) evidence of this is the old posts you linked to. – Steve Robillard Oct 22 '17 at 17:49
  • Preferred or not, the preferred version did not work for me. This way did. it's a valid answer despite not being preferred, and some people may find it useful for getting an initial wifi connection that they can then modify to get the preferred version. – Retiarius Oct 22 '17 at 20:02