Give Others Access

Updated

You can let other people use your hosted Mac: your clients, your teammates, a contractor. Give each person their own macOS user and their own SSH key. Don’t share your own key or password.

It’s Allowed

You’re responsible for everyone you let in. That covers the users and keys you give out, and everything those people run on the Mac. The Terms of Service say so under Your Account and Security and Acceptable Use. What they do on the Mac counts as your use of it. Report Abuse lists the checks that run on every Mac.

Make a User for Each Person

Connect to the Mac over SSH. Then make the user. Swap alex and Alex Kim for the person’s user name and full name.

sudo sysadminctl -addUser alex -fullName "Alex Kim" -password -

sudo asks for your own password. Then sysadminctl asks for the new user’s password. Set one even if they’ll only use SSH. They need it for Screen Sharing.

You can also do this on the Mac’s screen. Over Screen Sharing, open System Settings, then Users & Groups, and press Add User.

Add Their SSH Key

SSH on a MacMetro Mac takes keys only, so each person needs a key. Ask them for the public half of theirs. It’s one line that starts with ssh-ed25519. Add an SSH Key shows how to make one.

Put their key in their user’s authorized_keys. Paste their whole key line between the single quotes. sudo -u alex runs each step as their user, so the files are theirs.

sudo -u alex mkdir -p /Users/alex/.ssh
echo 'ssh-ed25519 AAAA... alex@laptop' | sudo -u alex tee -a /Users/alex/.ssh/authorized_keys
sudo -u alex chmod 700 /Users/alex/.ssh
sudo -u alex chmod 600 /Users/alex/.ssh/authorized_keys

Run the same steps to add another key later. Never write into their .ssh folder as root. They control that folder, and a link there could point root at your own keys.

They connect with your SSH command, with their user name in place of yours.

ssh alex@<your-mac-address>

On a Mac reached through Cloudflare, they also need cloudflared and the ProxyCommand from Connect Over SSH.

For Screen Sharing, they open the tunnel from Screen Sharing with their own user name. Then they sign in with the password you set for them. Any other port they need goes through an SSH tunnel too (see Open Ports and Port Forwarding).

If Only Some Users Can Connect

In System Settings, open General, then Sharing. The info button next to Remote Login shows who can connect. If it says Only these users, add the person:

sudo dseditgroup -o edit -a alex -t user com.apple.access_ssh

Screen Sharing has the same setting. Its group is com.apple.access_screensharing.

Standard Users and Admins

The command above makes a standard user. A standard user can’t use sudo or change other users’ files. Make someone an admin only if they need it:

sudo dseditgroup -o edit -a alex -t user admin

An admin can do anything on the Mac. That includes deleting your user or the hidden support account that delivers your SSH keys and runs installs.

Remove Access

To take away one key, delete its line from the user’s authorized_keys.

sudo -u alex nano /Users/alex/.ssh/authorized_keys

Taking a key away doesn’t end a connection that’s already open. To end their sessions now:

sudo pkill -u alex

To remove the person, end their sessions first with the command above. Then delete their user. Their home folder goes with it, so copy off any of their files you need first.

sudo sysadminctl -deleteUser alex

Why Not the SSH Keys Page

The SSH Keys page adds a key to your own user, on every Mac in the account. Anyone with a key there signs in as you, with your files and your admin rights. Keep that page for your own computers.

After a Reset

A Reset erases the Mac, and the users you made go with it. Your own user comes back, with the keys from the SSH Keys page. Make the other users and add their keys again.

Need help? Email support@macmetro.com.