Setup your mac for remote SSH login and file transfer

Set your sharing options

Open System Preferences and then Sharing.



In the sidebar make sure that the option Remote Login is ticked. If not turn it on. If you can’t change it is because these settings are protected from accidentally changing them. If that’s the case click on the lock at the bottom of the window to make changes.

Once this is enabled and selected on the right side of the window you can read ” To log in to this computer remotely, type “ssh mimo@Maurizios-MacBook-Pro”.”
If you try that on the same machine it’ll work, but not if you don’t have DNS setup internally on your machine. So assuming that is not the case you’ll need to find the right IP address.

Get the right network configuration

Open the network preferences and select the adapter that gives you access to the internet. The internal network IP address is given on the right-hand side where it says: Wi-Fi is connected to Your Network Name WiFi and has the IP address 192.168.0.123.

Now if you have an internal IP address, and you’re going to SSH from another machine in the same network you won’t need any other configuration, otherwise, you’ll have to make your computer be exposed to the external network.

Test your SSH

What you can do now is to try in a terminal tab to connect via SSH to your own computer. Type: ssh yourusername@youripaddress in my case, it looks like this: ssh mimo@192.168.0.123. If everything goes well you’re going to be asked for the password, which is the same one you put when you log in to your computer.

Done!

At this point you can use SSH to connect to your own computer while connected to another machine, for example, a colleague’s computer or a server.

A couple of useful commands:

Copy files via SSH from a server to your local machine:

scp ./myfile.txt mimo@192.168.0.123:/Users/mimo/Desktop/

Another way around:

scp mimo@192.168.0.123:/Users/mimo/Desktop/myfile.txt .

Copy an entire folder via SSH from a server to your local machine:

scp -r ./myFolder mimo@192.168.0.123:/Users/mimo/Desktop/