0

I'm trying to SSH into a RPi from a Macbook Pro so I can run commands on the pi without hauling around an extra keyboard, monitor and mouse.

I can't connect via an ethernet cable because my macbook doesn't have an ethernet port.

I've successfully connected through a shared network, but I want to connect to it in a place I don't have a router/switch available.

I've spent days trying to figure this out and am at my wits end, and I can't seem to find a solution anywhere that specifically solves my problem of not being able to connect via ethernet with a pi-2. Does anyone know how to accomplish this?

darksinge
  • 103
  • 4

4 Answers4

3

Your Mac can create an ad-hoc network that you can connect your Raspeberry Pi to.

Just click the WiFi symbol at top right of your Mac screen and create a network with the name of your choice. Configure your Pi to connect to it.

See here.

Mark Setchell
  • 256
  • 1
  • 6
  • This was by far the easiest and most simple solution. I can't believe I spent so much time trying to make this work when it took just a couple of minutes until I could ssh into my RPi using this method. Best part is I didn't have to purchase extra paraphernalia like a USB ethernet adapter, etc! – darksinge Oct 24 '17 at 21:39
  • For those who might be interested, I found this short article that shows how to create the ad-hoc network with your raspberry pi, which could be useful if you're unable to create it using your normal PC. I tested it out and it worked using RPi 2 Model B running Stretch. – darksinge Oct 24 '17 at 21:42
  • 1
    Glad it worked for you, and thank you for sharing the article on how to do it from the other side. Good luck with your project! – Mark Setchell Oct 25 '17 at 06:25
0

You can use a USB to serial (TTL) adapter. This will allow you to watch the system boot and run commands. It requires you hoot up the adapter to the header pins.

jdwolf
  • 131
  • 4
0

Since you can't use an ethernet cable, the Pi 2 will have to have a wifi adapter. If you cannot do that, then you are out of luck -- unless you want to get a USB serial cable and use the Pi's serial port, but in that case, it would make more sense to get a USB ethernet adapter. They are slightly more expensive (say $20 vs $10) but ethernet will be much, much, much better than a UART (serial) link.

Presuming you have a wifi adapter for the Pi, you can then set one or the other up as a wifi hotspot and have the other one connect to it. If you've ever shared your phone's internet access with a non-cellular device, this is exactly the same idea, except no one will have any internet to share.

There are many tutorials online and some Q&As here about setting up the Pi as a wifi hotspot. Note that much of that may focus on sharing internet, which obviously you don't have to be concerned with; you are going to end up with a network of 2.

The adapter must support access point (AP) mode; most of them do. To check:

iw list

This outputs quite a bit. Near the top should be a list, "Supported interface modes", which will include "AP" and/or "AP/VLAN" if the adapter is hotspot capable.

The two fundamental pieces of this are:

  • hostapd, which I presume is short for "host access point daemon".
  • A DHCP server implementation, e.g., dhcpd (note: not dhcpcd, the extra "c" being for client, whereas you want a server). This is responsible for providing the connected Mac with an IP.

Of course, you may find it easiest to set the Mac up as the hotspot instead.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
0

I'd suggest a USB to LAN adapter (very cheap on eBay) and set static IP addresses on both devices.

Or the hotspot method mentioned above.

Or - use a smartphone with hotspot, Fing (to scan for the R-Pi IP and scan running services) and JuiceSSH (for the SSH bit)

Andy Anderson
  • 638
  • 1
  • 4
  • 11