How to Enable SSH on Mac from the Terminal

The world is quickly filling up with smarter people who search for smarter ways to work. In this world of smarter brains, working on multiple locations from a single place is a small thing. Many professionals are using remote login protocols to work on multiple machines right from their notebooks. Modern Mac books come with SSH pre-installed but not enabled by default. But you can enable SSH on Mac from the terminal quite easily.

SSH (Secure Shell) is an encrypted remote login protocol used to connect to remote machines over the network. This protocol encrypts communication from end-to-end server and client machines. SSH protocol is preinstalled by default in all modern Macbooks but the daemon is disabled by default. Mac users can simply enable SSH on Mac using simple terminal commands. You can enable SSH on all versions of macOS and Mac OS X by using the below tutorial.

Check SSH status on Mac

Before we start, let’s check the current status of SSH on your Macbook. You can do this by using the system setup command below:

sudo systemsetup -getremotelogin

If the remote login and SSH is currently enabled, the output will say “Remote Login: On” If SSH is disabled, it will say “Remote Login: Off”.

How to Enable SSH on Mac from Terminal

Open the terminal on your Mac.

You need administration privileges to enable SSH on your Macbook. Use the below system setup command to enable SSH on Mac:

sudo systemsetup -setremotelogin on

There won’t be any confirmation message for the above command. So, you need to check the SSH status using the “getremotelogin” command:

sudo systemsetup -getremotelogin

Now you can remote login to another machine using its IP address:

ssh technastic@eagle.example.com

You need to provide authentication of the user “technastic” on the machine “eagle.example.com”

How to Disable SSH on Mac from Terminal

If you feel that you no longer use SSH on your machine, then you can simply turn it off to avoid unauthorized access. You can simply disable SSH on your Mac using the below command:

sudo systemsetup -setremotelogin off

You’ll be asked for confirmation to disable the SSH “Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally on the server (yes/no)?” Type “yes” to confirm.