How to SSH Into Another Mac: Mac-to-Mac SSH Guide

The Wizard's Pages

 

SSH from One Mac to Another Mac

Can I access my remote Mac from the Terminal on my local Mac? You can use SSH to remotely access another Mac from Terminal. Once Remote Login is enabled on the target Mac, you can connect using its username and IP address

Here's how to copy files from one Mac to another Mac or maybe you want to move files from an old Mac onto a newer Mac

You can also use SSH on your local Mac to edit, delete, rename, move or in any other way work with files on a remote Mac

This tutorial shows you how to use SSH to move and share files between two Macs

It also shows you how easy it is to work with files remotely

If you have two Macs sharing the same wifi you have everything you need to SSH from one Mac into the other Mac

Follow me like a panther and I'll show you how easy it is to SSH between two Macs

Access one Mac from another Mac Use ssh to login to a remote Mac In system settings enable Remote Login run ssh username@hostname using the target Mac's username and IP address how to use ssh SSH into another Mac SSH from Mac to Mac SSH login to Mac how to SSH into another Mac how to SSH from one Mac to another connect to another Mac using SSH remote login Mac using SSH Mac SSH remote login how to connect two Macs with SSH remotely control another Mac using SSH access files on another Mac using SSH Mac Terminal SSH connection

How to Access Two Macs Using SSH

Image Showing How to Use SSH to Access One Mac from Another Mac

First Open System Settings () on your Remote Mac and under Sharing make sure Remote Login is enabled

Find that Mac's IP Address and copy it and paste it somewhere handy or just write it down

You can find a Mac's IP Address in System Settings > Network in the left sidebar then select your active connection, such as Wi-Fi or Ethernet and then click Details under your Network Name and there you should find your IP Address

The fastest and easiest way to find the IP Address on a Mac is to open the Terminal and type

ipconfig getifaddr en0

for Wi-Fi or

ipconfig getifaddr en1

for Ethernet

Your username and the name of your machine or Computer Name are two completely different things and you will need your username on your remote Mac to SSH into it

To find your user name run this in the Terminal:

whoami

Then open the terminal on your local Mac and confirm that OpenSSH is installed on your machine by checking the version of SSH you have by running this in your terminal

ssh -V

and you should see something like OpenSSH_9.0p1, LibreSSL 3.3.6

SSH Into Your Remote Mac

In your Terminal type ssh the user name on the remote machine followed by the @ symbol and the remote Mac's IP address so that your command looks like this:

ssh username@TargetMacIPaddress

and press Enter key and enter your password when prompted and press Enter again

The first time you connect, you will be prompted to accept the authenticity of the host. Type yes and press Enter. Then, enter the password for the user account on the target Mac

You are now in the Terminal/Command Line in your remote Mac and any command you enter now, will be run on the remote computer

To get back to your local Mac type: exit and then Enter


This article is part of the Scoroncocolo macOS Terminal Tutorial Series

How to Set Up an SSH Key Pair

Image Showing How to SSH from your Mac into another Mac

To make things easy during future sessions, you could setup an SSH key pair so that you do not need to enter a password when connecting via SSH in the Terminal

SSH keys are pairs of cryptographic keys (public and private) used to authenticate to servers and remote computers securely, replacing passwords for login

Run this:

ssh-keygen -t ed25519 -C "your_email@example.com"

The setup will ask you two things and the first is are you ok with where it plans to store the file containing the keys you are about to generate

Press Enter to accept the default file location which will be at (~/.ssh/id_ed25519)

Next it ask if you would like to set a password

can decline to set a password by pressing Enter twice

You now have two files in your ~/.ssh/ directory: id_ed25519 — Your Private Key and id_ed25519.pub — Your Public Key

Generate an SSH key on your local Mac

Next you must install the public key onto the remote Mac so that you can SSH into it

In Terminal on your local Mac:

ssh-copy-id username@remote-mac-ip

Replace username with your username on the remote Mac

SSH Into Your Remote Mac

Now login to the remote Mac by running this

ssh username@TargetMacIPaddress

You’ll be prompted for the remote Mac’s password once

You can give your remote Mac a nickname that allows you to type a simple alias like ssh oldmac instead of having to always type your username followed by a long IP address

You do that by editing your local ssh configuration file located at ~/.ssh/config

Run this

vim ~/.ssh/config

You’ll probably have a blank config file and that’s fine, so here’s what you will need to add to it:

So now your SSH config file looks like this

Host oldmac
    HostName 192.168.1.069
    User yourusername

Next to the word Host place the nickname and next to HostName place the remote Mac's IP address and next to User place the remote Mac's username

Now just run this to SSH into your remote Mac

ssh oldmac