How to do SSH on macOS

Sameer Gurung
2 min readJan 17, 2024

--

To perform SSH (Secure Shell) on your local laptop running macOS, you need to follow these steps:

  1. Open the Terminal: You can find the Terminal application in the Applications/Utilities folder or search for it using Spotlight.
  2. Enable SSH Server (if not already enabled): macOS comes with an SSH server called OpenSSH, but it’s not enabled by default. To enable it:
  • Go to System Preferences.
  • Click on Sharing.
  • In the list on the left, check the box next to Remote Login. This turns on the SSH server. (You’ll also see the ssh yourusername@yourIPaddres over there. If not, follow the steps below.)

3. Check Your Username and IP Address:

  • Your username is usually the name of your home folder in /Users. You can also find it by typing whoami in the Terminal.
  • To find your IP address, go to System Preferences > Network. Select the network you are connected to (Wi-Fi or Ethernet), and you'll see your IP address listed.

4. Connect to SSH Locally:

  • To SSH into your machine from the same machine or another machine on your local network, open Terminal and type:
ssh yourusername@yourIPaddress

For example, if your username is john and your IP is 192.168.1.2, type:

ssh john@192.168.1.2
  • If you are trying to SSH into your Mac from the same Mac (i.e., connecting to itself), you can use localhost as the IP address:
ssh yourusername@localhost

5. Accept the Connection (if first time): The first time you connect to a machine via SSH, you will be asked if you trust the connection. Type yes to continue.

6. Enter Your Password: After the connection is established, you will be prompted for the password of the user account you are logging in with.

Remember, SSH allows you to control your Mac through the command line, so it’s important to have some familiarity with terminal commands. Also, ensure your network is secure when using SSH, especially if you enable remote access from outside your local network.

--

--

Sameer Gurung

A Software Engineer, who also turns to be a JavaScript enthusiast. Currently working with NodeJs, Angular, Ionic and AWS. Catch me: https://smrgrg.com