27

To keep myself entertained during the COVID-19 pandemic, I've bought a Raspberry Pi. I thought that it would be possible to program it from my laptop over SSH using an Ethernet connection, but I've just discovered that this requires me to know the IP address of the Raspberry Pi.

Without a keyboard/mouse to plug into it, I can't set up the Raspberry Pi's Wi-Fi and/or check its IP address (as far as I'm aware) using a monitor.

Without an SD card reader, I cannot follow a tutorial such as this for headless setup.

Can anyone think of a way around this?

The Raspberry Pi already has an SD card in it with the Raspbian operating system installed on it.

hlecuanda
  • 103
  • 4
John Smith
  • 397
  • 1
  • 3
  • 6
  • 1
    Do you have a ttl-level USB to RS232 serial dongle? – slebetman Apr 17 '20 at 07:30
  • I can't be bothered to write this again, as an answer, but here's how I connected it [over ethernet](https://eric.mink.li/publications/ethernet_ip.html) to my windows pc. Once you're connected, you can set up a cron job that connects to your wifi so you don't need to do this every time – lucidbrot Apr 17 '20 at 13:12
  • This was recently covered on Hacker Public Radio (also about finding the IP address of a Raspberry Pi): *[Locating computers on a network](http://hackerpublicradio.org/eps.php?id=3052)* (episode 3052) – Peter Mortensen Apr 17 '20 at 13:18
  • `nmap -sn 192.168.1.0/24` usually does that for me. Note that network may vary. – Andrew Savinykh Apr 19 '20 at 23:42
  • Related: https://raspberrypi.stackexchange.com/a/13937/57444 – Captain Man Apr 20 '20 at 18:47
  • I'm really curious as to why you can't just buy a keyboard for $20, or an SD card reader for $10. EBay delivers. – Peter Wone Apr 30 '20 at 00:33
  • Have you tried inserting the microSD into your phone or ereader, then connecting *that* to a computer to do the configuration? Basically treating your phone/ereader as an overgrown microSD card reader ;) – Hippo Apr 30 '20 at 08:40
  • 1
    SD card reader should be a mandatory purchase if you have a Pi. Even if you work around it today, you'll need it tomorrow. Also regarding keyboards, a cheap-as-possible compact USB keyboard is good to have around... even getting into the BIOS on many PCs cannot be done without a wired keyboard – Greg Woods Apr 30 '20 at 09:02

13 Answers13

29

Welcome to the world of Pi - you will get many hours of fun from them once you are up and running.

First check with your supplier to see if the version of the operating system they put on the card had ssh enabled - most suppliers do not do this though. If not:

  • Try ping raspberry.local - it may find it.
  • Check your router to see if you have a new device
  • Look at a ping program for your computer or 'phone / tablet - I use one called fing

Once you have the IP address you need to load and use PUTTY on a PC or ssh from the terminal of a Linux or Mac computer.

ssh pi@x.x.x.x

where x.x.x.x is the IP address of the Pi from above. Sorry I do not use PUTTY but plenty of guides on the internet :-)

If that does not work then unfortunately without a SD card reader/writer you are stuck as you do not have ssh enabled - as a bare minimum you need to be able to add a file call ssh to the /boot partition of the SD card then you can access it via ssh pi@raspberrypi.local from a Mac, Linux or an up to date Windows PC.

You can get low cost USB to SD card adapters - that will take a few more days of waiting though.

  • 8
    Note that raspberry.local uses Apple's Boujour protocol which by default does not exist on Windows. A neat trick to make it work on Windows is to install iTunes for Windows. On Linux it sometimes works automatically but if it doesn't then you don't have Avahi installed – slebetman Apr 17 '20 at 07:32
  • 3
    @slebetman Windows calls it Zero Configuration Networking and its been available since 2005 https://www.microsoft.com/en-us/research/video/zero-configuration-networking-with-bonjour/ M/S broke its own implementation about two years ago but fixed it again. You can install iTunes or just Bonjour from Apple to make it more stable or hope M/S do not break it again :) –  Apr 17 '20 at 12:20
  • 2
    Zero conf on Windows is a different protocol that is incompatible with Bonjour and does not implement the .local domain which is part of a DNS based protocol developed separately by Apple after Windows released zero conf. In early 2020 the .local domain still does not work in Windows (tested on both Windows 7 and Windows 10 when I instructed my employees to connect to the test server using the .local domain and I discovered that Windows does not support it as of February 2020) – slebetman Apr 17 '20 at 12:30
  • @slebetman Works here - my music server (lr-music.local) is fine and no Bonjour on the PCs. Service packs strike again... –  Apr 17 '20 at 12:42
  • 3
    I did some googling around and found that Windows only support mDNS (.local domain) in newer applications built with .Net 4.6 and above: https://social.technet.microsoft.com/Forums/en-US/8a0346de-2296-4f46-bc36-ff3fb13e283b/builtin-mdnsdnssd-zeroconf-support-in-windows-10. This explains why none of our software can connect to .local domain as they are all Java8 based. Older .Net and win32 apps cannot access .local domain without installing something like Bonjour – slebetman Apr 17 '20 at 12:51
  • 5
    @slebetman That's wild. "Today we will be setting up our Raspberry Pi. To be able to SSH into it, please first download iTunes onto your Windows 10 desktop." – Captain Man Apr 17 '20 at 18:53
  • 1
    @CaptainMan To be fair, the minimum amount of software you need to install is Bonjour Print Services from Apple which will set up mDNS for you but I usually find it easier to tell people to install iTunes – slebetman Apr 18 '20 at 06:04
  • I find the easiest solution for finding pi IPs on my Windows machine to be [Advanced IP Scanner](https://www.advanced-ip-scanner.com/) -- it's quick, easy, and user friendly (I'm not affiliated with them, but I'd definitely rather install their tool than the entire iTunes stack; iTunes has caused me headaches in the past, YMMV). EDIT: BTW, I'm assuming this is your home network. Scanning a work network is likely to bring the IT guys knocking on your door. – A C Apr 18 '20 at 21:02
  • @AC It may be simpler to do this (use nmap): https://raspberrypi.stackexchange.com/a/13937/57444 – Captain Man Apr 20 '20 at 18:46
  • About the "find the IP of the Raspberry Pi" part, if you are on Windows I suggest you a script I just described here as an answer: https://raspberrypi.stackexchange.com/a/111897/119023 – Kar.ma Apr 29 '20 at 13:54
  • I fail to see why this "Answer" was upvoted and accepted - because it is **wrong** - `ssh` is disabled on Raspbian and can only be enabled by editing the SD Card, or logging in to the Pi. – Milliways May 02 '20 at 11:46
10

To find the IP address of your Raspberry Pi, you can try one of the following:

  • ping with common names (rpi, rpi4, rpi3 and raspberry)
  • look at your router administration console to list all devices on the LAN
  • use tools for LAN analysis (like Fing for Android)

If ssh is not enabled by default, if you don't own an SD reader nor a USB flash drive, nor a USB adapter for microSD cards, you will probably be stuck.

Danilo Schembri
  • 101
  • 1
  • 6
  • 1
    Re `raspberry` (on the network): Not `raspberrypi`? – Peter Mortensen Apr 17 '20 at 13:54
  • Try both. If one works ... – waltinator Apr 20 '20 at 00:27
  • All Pi computers using Raspbian by default are named raspberrypi.local as this is the name built into the image. As you never seem to have just one pi (you may start with one but the seem to grown) it should be changed ASAP as two computers with the same name on the same network is an issue... Unless you have the weird software I have on your PC (Macs are fine) then load https://support.apple.com/kb/DL999?locale=en_GB but some Windows service packs can break this see https://superuser.com/questions/1330027/how-to-enable-mdns-on-windows-10-build-17134 for one fix –  Apr 30 '20 at 23:41
9

According to What are the possible OUIs for the Ethernet MAC address, there are exactly two OUIs used by Raspberry Pi devices as of April 2020.

This is confirmed by Raspberry Pi Foundation - MAC vendors list.

One solution would be to search your desktop system's ARP table with:

linux>    sudo arp -a | tr -d : | egrep "b827eb|dca632"

windows>  arp -a | findstr dc-a6-32
windows>  arp -a | findstr b8-27-eb

You might need to fill your ARP table with a command like fping (I am not sure if there's a Windows equivalent)

 linux>      sudo fping -a -g 10.99.99.0/24

You could also use Nmap to find all hosts on your LAN that listen for SSH:

 linux>      sudo nmap 10.99.99.0/24 -p 22

These would not be my first solutions - I'd check the DHCP logs in my firewall in the first instance.

Peter Mortensen
  • 1,984
  • 2
  • 14
  • 17
Criggie
  • 272
  • 1
  • 7
8

It is possible to access the Pi over serial terminal, but this requires a USB-serial dongle on the laptop.

It is far easier to buy a SD Card reader to enable ssh - these are available for < $5.

Once enabled you can ssh into the Pi over Ethernet using a Link-local address with the Pi's hostname (raspberrypi by default)
ssh pi@raspberrypi.local

This works using with most OS although other variants on raspberrypi may work on Windows.

Milliways
  • 54,718
  • 26
  • 92
  • 182
8

xkcd butterfly

Are you looking for a theoretical solution, or a practical one?

SD cards have SPI interface as well, so as long as you can provide a stable 3.3V for powering your card and a debounced clock signal, a few additional switches and wires could solve it. (maybe add an LED and a series resistor to MISO to have some feedback)

There's a video where an Atmel AVR chip is programmed by hand through SPI similarly. The SD card's protocol is different, and this is not practical nor recommended. But in theory it's possible to read/write anything.

Let's program an AVR manually

Nyos
  • 701
  • 5
  • 6
  • But an AVR microcontroller may not have enough RAM for the ***required*** buffers for newer SD card interfaces, like [SDHC](https://en.wikipedia.org/wiki/Secure_Digital#SDHC) (all SD cards these days - you can no longer buy the old ones (nominally at or below 1 GB)) – Peter Mortensen Apr 17 '20 at 14:14
  • It doesn't need to, because you don't need it. You could - in theory - program the SD card by directly wiring up VCC and GND to a 3V3 power supply, its MOSI to a switch, its MISO to an LED and a series resistor, and its SCK to a debounced button. Just like in the video, only put the card in place of the AVR. You might need some pen and paper, also very good patience, dexterity, and memory. – Nyos Apr 17 '20 at 14:23
  • 1
    That's the spirit, the rest is so ... _pedestrian_. I was expecting something like "connecting GPIO x and y via a resistor causes it to crash to terminal and this-and-this hairpin has the right resistance" or some such. You know, like using Ikea coffee tables for cheap home 19" racks, CD audio cable ends for HP 48 calculator serial cables and whatnot. – chx Apr 18 '20 at 03:54
  • Why do I expect that YouTube URL to go to a famous Rick Astley video? – rugk May 04 '20 at 20:00
6

Contrary to popular belief, there is also a way of booting the Raspberry Pi without using an SD card at all! All of the previous answers recommended impractical ways, and the same applies to this method, though I hope you find it much more practical than what was previously suggested.

Method 1: Booting from a MSD (Mass Storage Device ie. USB Flash / Thumb Drive)

First of all, I'd like to point out that you can boot your Raspberry Pi via a USB. However, this only works if you're using any of the following models (OR if you have an SD Card Reader):

  • Pi 2B v1.2
  • Pi 3A+
  • Pi 3B
  • Pi 3B+

Unfortunately, if you do not have an SD Card Reader and your model is not one of the supported ones listed above, you cannot use this method.

If you have a SD Card and a SD Card Reader, then this guide is for you!

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md

Method 2: Making the computer serve all the files to the Raspberry Pi

For this method, you will not even need an SD card to get your Pi up and running! You will just need to connect the DATA MicroUSB port on your Pi to your computer!

This method will only work for the following Raspberry Pi models:

  • Pi Compute Module
  • Pi Compute Module 3
  • Pi Zero
  • Pi Zero W
  • Pi A
  • Pi A+
  • Pi 3A+

See this official GitHub project if you're interested! https://github.com/raspberrypi/usbboot

Your computer will serve all the files needed for the Raspberry Pi to boot (make sure you read the "Running your own (not MSD) build" part in README.md; that is what you want to do).

idontknow
  • 161
  • 4
  • You still need an SD card reader to make the changes in the second option. –  Apr 19 '20 at 15:29
  • @Andyroo No, that is incorrect. You only need to remove the SD card for it to try booting into that mode. See https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/device.md for full details. – Toothbrush Apr 19 '20 at 17:18
  • @Toothbrush Apologies - I see how that works now but the Pi would boot from the OPs card first and I would not like to put the only card I had in a **powered Pi SD slot** to add the ssh file to it :-) The second options (not MSD) does state *copy the FAT partition files into a subdirectory* hence the reader requirement above. –  Apr 20 '20 at 11:13
  • 1
    @Andyroo No, it is not required. _"When this boot mode is activated (**usually after a failure to boot from the SD card**), the Raspberry Pi puts its USB port into device mode and awaits a USB reset from the host. […] The host first sends a structure to the device down control endpoint 0. This contains the size and signature for the boot (security is not enabled so no signature is required). Secondly, code is transmitted down endpoint 1 (`bootcode.bin`)."_ — https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/device.md – Toothbrush Apr 21 '20 at 17:51
  • 1
    @Andyroo _"you just need to copy the FAT partition files into a subdirectory (it must have at the minimum `bootcode.bin` and `start.elf`)"_ is trying to say that you need to copy the files which are necessary to boot the Raspberry Pi firmware to the directory which `usbboot` reads from and sends to the booting Raspberry Pi. It goes on to explain that copying the full kernel distribution will not work by default. _"To provide a filesystem there are many options, you can build an initramfs into the kernel, add an initramfs to the boot directory or provide some other interface to the filesystem"_ – Toothbrush Apr 21 '20 at 17:53
  • But for the OP to do that from the card he needs an SD card reader so its back to the original issue. You could try dragging the files out of the ISO I suppose but the last time I tried that the Mac had issues with the mixed disk types. YMMV –  Apr 21 '20 at 20:11
  • Out of curiosity, but if you boot the Raspberry Pi without an SD card, can it be used as an SD card reader since the user can ssh into the Pi and then access the card? – idontknow Apr 21 '20 at 22:22
4

Newer raspberry PIs will boot from the USB port. You can install raspbian on the USB stick with the usual process. When it boots you plug in the SD card (don't do it before the boot or it'll try booting from the SD card) and write the data there.

  • 2
    Not quite. The Pi 2B v1.2, 3A, 3B needs to boot from SD first to have a control bit set, the 3B+ will boot from USB and the 4 will do one day but not as yet. https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/bootmodes/msd.md –  Apr 17 '20 at 22:24
3

If the Raspbian installation already has SSH enabled and you know the password, it is only a matter of finding the IP. However, the default installation has SSH disabled.

If you have a Raspberry Pi 3B+ and a USB drive, you can install ssh-enabled Rasbian on the USB drive and boot from that. Unfortunately the other Raspberry models do not boot from USB by default.

Alternatively, you might have a SD card writer you do not know about. For example many phones and digital cameras have SD card slots, and give access to that from PC when connected. To follow the tutorial you linked in your question, you only need to create two text files on the card.

jpa
  • 414
  • 2
  • 5
3

Rasbpian boots up with IPv6 enabled by default. Provided your laptop supports IPv6, too it solves all your problems:

First, broadcast ping your local network:

ping6 ff02::1%eno1

All the machines will answer. Log in via ssh (just try all adresses):

ssh pi@fe80::f000%eno1

eno1 refers to my laptop's ethernet device in this example.

Hermann
  • 131
  • 3
  • that may well find the IP address (assuming the LAN supports IPv6 - some do not) but does not enable ssh (SD card adapter is still needed to enable ssh over IPv6) - Serial is the only way to go in these cases :-( –  Apr 18 '20 at 14:18
  • Dang. I completely forgot ssh is not enabled by default. – Hermann Apr 18 '20 at 17:24
3

Yes, there is quite convenient method. Take a look at PiConfig - Raspberry Pi Network Configurator: https://www.kickstarter.com/projects/827010089/raspberry-pi-network-configurator-piconfig

https://www.geeky-gadgets.com/piconfig-raspberry-pi-network-configurator-23-03-2015/

This is a pendrive dedicated to set up a raspi. It was successfully funded at Kickstarter five years ago and it seems one can still buy it. PiConfig plugged into RPi

rha
  • 131
  • 1
2

From the constraints you mention (no USB keyboard available and no SD-Card reader to modify the Raspbian image to contain your wifi credentials), there is only one option left. That is attaching a serial console to the Raspberry Pi and then you have full access. RPi Serial Connection

For attaching a serial console you will need a special USB cable which can connect to the right header pins on the Pi. Search for "Raspberry Pi serial USB cable" of "Raspberry Pi USB console cable". If you have an FTDI converter laying around you can use that.

Instead of a cable you could also use an ESP8266 and do serial over Wifi ;)

The next best option without a SD-Card reader/writer, is to borrow a USB keyboard from your neighbours. With that you can connect the PI to your television over HDMI and use the keyboard to log in and modify the wifi credentials. It's even possible to do this without a mouse by interrupting the boot and adding

init=/bin/bash

after the boot command. This way raspbian will boot up in text mode.

beamzer
  • 21
  • 2
2

There is the option of network boot, some details can be found here. It uses another raspberry as network boot server, but any machine can act as it.
I don't have any raspberries so I never tried it with them, I did it many years ago with normal x86_64 machines, a bit cumbersome to configure, but it works.

0

Actually you cannot generally run a Raspberry pi without a SD card, as it stores the operating system it will be running. It's the secondary memory unit of the Raspberry Pi. But alternatively you can also use a pendrive (in the first place), to use a bootable hard drive, and run your your Raspberry Pi.

Now you can do two things very interestingly, 1.connect your raspberry pi with your network (use an Ethernet medium to avoid credentials input), and go to your Router to find out your Raspberry Pi IP address. That you can do by going to the 'Connected Client Status' on your Router. 2. Using your Raspberry pi IP, connect your PI, by SSH or you can use VNC (search on internet how to connect to Raspberry pi with VNC, this is easy af) and enjoy yourself.

N.T. for your entertainment purpose, you can use Volumio, MusixBox, or RuneAudio Operating Systems over Raspberry pi. (I'm not sure whether you can make portable hard drive medium, for these OSs, but if such, go for Raspbian or Raspbian Noobs or other Linux Frameworks).

All the best.