DEV Community

Cover image for Connect To Your Raspberry Pi From a Mac 🧰
Stan Kukučka
Stan Kukučka

Posted on • Edited on

Connect To Your Raspberry Pi From a Mac 🧰

Your Laptop and Raspberry Pi connected

You are close to making this happen. Your Raspberry Pi OS is already copied onto an SD card (as explained in previous tutorial) and plugged into a Raspberry Pi slot. There are a few steps to make this piece of tiny hardware work for you. So let's make this magic real, let's slice and dice it whole.

Enable SSH on Raspberry Pi

In this step, you definitely need to connect your Raspberry Pi into power with Micro-USB-B on one side with standard USB on other side and plugin at least a USB mouse and yeah, don't leave your HDMI port empty to plug in some monitor too. The whole Raspberry OS should boot into the nice and tight interface. Click on the berry icon on the very left top corner and lead your mouse to Preferences > Raspberry Pi Configuration as seen on the next screenshot.

Alt Text

This window will pop-up in the middle of your screen. There is a place to rename your Raspberry device in the section named as Hostname or keep it default as raspberrypi. Remember this Hostname serve device connection in connection command, so if you rename it here don't forget to rewrite in command too. Example for SSH connection where whole command to serve device is pi@raspberrypi.local, but will come to this point later.

Alt Text

To activate SSH click on the Interfaces on the top part of the window and press the radio button Enabled where SSH info is mentioned. SSH itself will help us to connect to Raspberry via terminal when it is connected to local network via UTP cabel or via wifi without monitor plugged into device later on.

Alt Text

Plug in Raspberry

There are two ways how to plug in your "razz" into the network. The first and the starting step as we are going to with is our first choice. Connect via UTP cable, in case we have the same port on the laptop.

Alt Text

Connect to Raspberry

There is no need to identify the IP address of your Raspberry Pi device. Just simply use SSH command and try to connect to raspberrypi.local with this command hereunder.



ssh pi@raspberrypi.local


Enter fullscreen mode Exit fullscreen mode

You'll be notified with this command hereunder.



Are you sure you want to continue connecting (yes/no/[fingerprint])? yes


Enter fullscreen mode Exit fullscreen mode

Type yes and you'll be asked for password.



pi@raspberrypi.local's password: 


Enter fullscreen mode Exit fullscreen mode

Default password to Raspberry device is raspberry

Now type exit

In this step we are going to get rid of the default password to make it more safer. So you'll log in again into Raspberry Pi via SSH, but with the additional command passwd to set up a new password.



ssh pi@raspberrypi.local passwd


Enter fullscreen mode Exit fullscreen mode

Pass the whole process of changing the actual password into the new one.

Turn on Wifi

If you are looking for wifi activation you should be already connected to Raspberry via SSH on UTP cable. Then paste this command to activate the configuration interface in the terminal.



sudo raspi-config


Enter fullscreen mode Exit fullscreen mode

This Software configuration tool will show up. Just select the first option as follows 1 System Options.

Alt Text

Then head to S1 Wireless LAN to setup wifi to connect to.

Alt Text

You'll be asked for SSID as the name of the wifi.

Alt Text

Enter passphrase to log into wifi.

Alt Text

Here will system freeze for a while then after you confirm the password just press simple FINISH in the main interface.

Connected over wifi

Now you can unplug UTP cable and let connect to your Raspberry Pi over SSH again. Your laptop and Raspberry Pi needs to be on the same wifi. You'll be notified by this informations hereunder.



Warning: Permanently added the ECDSA host key for IP address 'HERE IS YOUR MAC ADDRESS' to the list of known hosts.


Enter fullscreen mode Exit fullscreen mode

And just enter the password to get into your "Razz" again. Be ready to follow this process anytime you reinstall the system of your laptop in other words connect to Raspberry Pi over UTP cable first, set up a wifi connection, and then you can easily realize an SSH connection via wifi.

Ready to roll with your "Razz"

Now is your Raspberry fully connected via wifi (or you can connect via UTP cable if you prefer). Check how long the device is up with this command.



uptime


Enter fullscreen mode Exit fullscreen mode

You can disconnect from the device with exit command when you'll stop the connection, but Raspberry Pi will still keep running.



exit
Connection to raspberrypi.local closed.


Enter fullscreen mode Exit fullscreen mode

Or to turn off the device entirely with a simple command.



sudo halt


Enter fullscreen mode Exit fullscreen mode

To give your Raspberry time to rest for your next upcoming projects.

Thanks to Harrison Broadbent for the cover image from Unsplash.

Top comments (2)

Collapse
 
rswork profile image
RS

Hi, thanks for the article - very useful.
I am novice to both Pi and apple macâ€Ķ
So "ssh pi@raspberrypi.local” does not connect (using Terminal on mack book pro)â€Ķ :-(
Any more descriptive way of connecting? may be via IP address i can try?
Thanks!

Collapse
 
stankukucka profile image
Stan Kukučka

Hi @rswork try ping raspberrypi.local to check IP of your rasp and then connect as ssh <username>@<ip address>.