SSH to Raspberry Pi from Mac OSX

Written by Stanley Semilla | Published at 25 April 2018

Recently, I've been doing side projects using a Raspberry Pi (RPi). There's a lot of sensors, devices and tools you can connect to a RPi. The benefits of using an RPi includes its size, wifi connectivity, and power consumption. Those three are major factors why I suggest using an RPi that involves sensors and monitoring devices. One problem I faced is connecting to the RPi without setting up a network/router. I wanted a direct connection from a laptop to the RPi. In my case, I use a 2016 MacBook Pro which uses a USB-C to Ethernet adapter. I just want to share how I was able to connect to the RPi via SSH with a direct ethernet connection from my Mac to the RPi.

First, get an ethernet cable.

Hook it up to your Mac and RPi.

Turn on the RPi.

Next, configure your Mac. You must enable Internet Sharing on your Mac.

To do that, go to System Preferences > Sharing.

While Internet Sharing is turned off, select where you want to Share your connection from. In my case, it's USB 10/100 LAN.

Screenshot-2018-04-25-11.54.50

Tick the checkbox to enable Internet Sharing.

Screenshot-2018-04-25-11.53.17

After that, go to System Preferences > Network.

Select the connection to your RPi on the left pane. Make sure Using DHCP is selected on the dropdown.

Screenshot-2018-04-25-11.58.12

Next, you should be able to see that you are connected.

Screenshot-2018-04-25-11.59.56

Once it's connected, we move on to the terminal.

Open your terminal, go to Applications > Utilities > Terminal. Or, open up Terminal using spotlight search. You can use your favourite terminal if you have one. I personally use iTerm.

Screenshot-2018-04-25-12.02.53

Type in ifconfig, and look for bridge100.

Screenshot-2018-04-25-12.06.42

Look for the inet field. For me, I'm getting 192.168.2.1

Next, type in nmap -n -sP -PS22 <Your IP Address>/24

Screenshot-2018-04-25-12.09.03

Now, you will see the other IP address connected to your machine. In this example, I get 192.168.2.3.

You can now use SSH to connect to the RPi using that IP Address.

ssh [email protected]

Type in your password, and you're good to go.

Screenshot-2018-04-25-12.11.00

Good job! You should be connected to your RPi by now.

Share this post Twitter or Facebook