How to Connect to a Raspberry Pi Via SSH Using the Macintosh Terminal

By Jeremy S. Cook

Freelance Tech Journalist / Technical Writer, Engineering Consultant

Jeremy Cook Consulting

March 31, 2021

Blog

How to Connect to a Raspberry Pi Via SSH Using the Macintosh Terminal
(Image Credit: Jeremy Cook)

As outlined in this November 2020 article, I recently switched from a PC to a Macintosh. Overall, I’m quite happy with the move, in a large part because it feels like they do all the “little” things right.

We can argue the relative benefits of a Windows or Linux PC, but printed pages are generally sized correctly, open windows snap side-by-side in an orderly (but not restrictive) fashion, and installing my Bluetooth trackball was nearly a matter of pressing a button.

For that matter, I just realized I haven’t had to worry about installing a driver in months, which actually seems quite strange now that I think about it. No, Macintosh computers aren’t perfect, but there’s a certain polish that I suppose comes from tightly controlling your hardware, plus perhaps having the right mix of visionary and tyrant in leadership.

SSH Connections First Steps:

One of the minor things that attracted me was the fact that you can log on to a Raspberry Pi remotely via SSH using the terminal–no PuTTY required. You’ll need to set the Pi up as previously outlined here and here for SSH usage. BalenaEtcher is conveniently available for macOS for imaging SD cards, and you can use the built-in TexEdit tool to modify settings for your SD card. In TextEdit Preferences you’ll want to select “Plain text” under for New Document tab, and uncheck “Add ‘.txt’ extension to plain text files” under Open and Save tab to avoid hassles.

​​​​​​​SSH via Terminal

Once you’ve got the Pi powered up and SSH-capable, you can figure out its network address via techniques outlined here. This may include an IP scanner, such as Angry IP Scanner, which conveniently runs on Mac. With the location known, fire up your terminal, and simply enter something like ssh [email protected]. Change “pi” to your username if it’s different, and the IP address to wherever you’re logging on. If all is well, you’ll be greeted with your Pi’s terminal prompt, where you can use and edit the system as needed. When you’re done, type exit to return back to working on your local machine, and perhaps even jump on to another Pi.

Alternatively, you can substitute in the hostname for the IP address, e.g. ssh [email protected], which can be quite convenient if you don’t have it handy. When you try to log on, you may gat a warning about DNS Spoofing, an annoying, but fixable problem, outlined in a bit more detail here. If you get this error, input nano ~/.ssh/known_hosts to delete the offending lines.

(Delete the line or lines of addresses that are supposedly spoofed)

​​​​​​​Serial Access Through the Terminal?

If you can SSH through the terminal, then certainly you could also use it for serial communication. As I’ve found, yes, this functionality can be accessed by entering the screen command, however, after attempting to use it for longer than I’d like to admit, I found myself generally hitting a bit of a brick wall. Documentation for it seems fairly spotty, perhaps meant for those who are “a few levels up” on the sysadmin knowledge chain.

So admittedly, having PuTTY available would be nice. While there are apparently ways to get this for Mac, instead of going down that rabbit hole, I’d instead recommend using the Arduino IDE serial monitor for this purpose. It may not do everything that PuTTY does, but when you add in the Terminal, there’s a good chance this combo will be sufficient for your serial/SSH needs!

Jeremy Cook is a freelance tech journalist and engineering consultant with over 10 years of factory automation experience. An avid maker and experimenter, you can follow him on Twitter [https://twitter.com/JeremySCook], or see his electromechanical exploits on the Jeremy S. Cook YouTube Channel! [https://www.youtube.com/c/jeremyscook]

More from Jeremy