How to SSH from a Mac to a Linux server on a home network

by panglott

This is so easy these days that I suspect much of the Internet just assumes everyone knows how to do it. But if there are Windows guides, we can have Mac-centric blogposts, too. You don’t need to find an IP address, or scan the network or whatever, thanks to Zeroconf.

First you have to get the sshd daemon running on the Linux server. If SSH is not installed, install it with the package manager:

sudo apt-get install ssh

Or whatever package manager you have. The way to start the sshd daemon depends on the Linux startup process used in your particular distribution/install. I use systemd, where (at a terminal window) typing:

sudo systemctl start sshd

should start the daemon. To enable sshd automatically on bootup, use:

sudo systemctl enable sshd.service

Also, make sure the Linux machine is running Avahi or equivalent. As long as the Linux and Mac OS X machines are both connected to the home network with DHCP and Zeroconf, they are accessible to each other over the .local domain name. So, if the hostname of the Linux server is remotehost, and your account name there is remoteuser, open on your Mac and type:

ssh remoteuser@remotehost.local

It’ll ask for your password, then give you access over the command line. Fun! There are other useful tools like secure copy, scp. So if you type:

scp ~/Backups/* remoteuser@remotehost.local:/home/remoteuser/backups

It will copy all the files in a home Backups folder to a backups folder at the remote home account.

See also:
* FUSE for OS X
* Remote SSH Into Your Home Mac Through iCloud’s Network (Lifehacker)