To enable SSH on your Mac using command line, we will use a command called systemsetup. The systemsetup command is a built-in macOS terminal tool that allow you to configure system settings directly from the command line.

To enable SSH, open your terminal and run the following command:

sudo systemsetup -setremotelogin on

You will be prompted to enter your administrator password. After entering the password, SSH will be enabled on your Mac.

To verify that SSH is enabled, you can run the following command:

sudo systemsetup -getremotelogin

If SSH is enabled, you should see the output:

Remote Login: On

If you want to disable SSH later, you can run:

sudo systemsetup -setremotelogin off

This will turn off the SSH service on your Mac.

Thats all