Password Sign-In Over SSH

Updated

Every MacMetro Mac takes SSH keys only. You can turn on password sign-in for one account on your Mac, such as your own or a colleague’s. Keys are still the easier and safer way in, so if a key works for you, add an SSH key instead.

Before You Start

Anyone on the internet can reach your Mac’s SSH and try passwords. Give the account a long password that you use nowhere else. To change it, open System Settings on the Mac over Screen Sharing and go to Users & Groups.

Turn passwords on for one account at a time, never for every account.

Leave /etc/ssh/sshd_config.d/010-macmetro.conf as it is. It keeps SSH keys only, and the hidden support account relies on that. MacMetro puts its own copy of the file back when the support account is restored or the SSH settings change, so edits to it don’t last anyway.

Turn It On for One Account

Connect over SSH and run this, with the account name in place of <username> both times:

printf 'Match User <username>\n    PasswordAuthentication yes\n' | sudo tee /etc/ssh/sshd_config.d/200-<username>.conf

It makes a file of your own that turns on passwords for that one account. It prints the two lines it wrote. The Match line covers only that file, so every other account still takes keys only.

macOS starts SSH fresh for each connection, so there’s nothing to restart. The next connection reads the new file.

Check It Before You Sign Out

Keep this session open while you check. If something is wrong, you can still fix it from here.

  1. Check the settings for mistakes. It prints nothing when they’re fine.

    sudo sshd -t

    If it prints an error, delete your file right away (see Turn It Off). While the file has a mistake, every new SSH connection fails, Screen Sharing included. If you can’t get back in, email support@macmetro.com.

  2. Check the account gets passwords:

    sudo sshd -T -C user=<username> | grep -i passwordauthentication

    It should print PasswordAuthentication yes. With user=macmetrosupport in its place, it should print PasswordAuthentication no.

  3. In a second terminal, sign in with the password. Take the command from the Mac’s Connect section and add two options after ssh, so your key isn’t used instead:

    ssh -o PubkeyAuthentication=no -o PreferredAuthentications=password <username>@<address>

    It should ask for the password and let you in.

Turn It Off

Delete your file:

sudo rm /etc/ssh/sshd_config.d/200-<username>.conf

The next connection takes keys only again.

After a Reset

Reset erases the Mac, your file with it, and the account gets a new starting password. To use a password again, set a long one and add the file again.

Restoring the support account leaves your file alone. Password sign-in for that account keeps working.