How do I force my Mac to log in to an account remotely?

It’s possible to restart a Mac from the command line (sudo shutdown -r now). It’s possible to log out from a Mac from the command line (sudo pkill loginwindow). But is it possible to force a Mac to log in from the command line? As in a full log in of an account, GUI-wise, not just logging in via SSH to the Mac via the Terminal.


Yes.

  1. Enable FileVault so you can escrow user and password securely
  2. sudo fdesetup authrestart sets the machine to restart and log in as the specified user after the restart.

This works for me remotely on new Macs with Big Sur. You may need ssh Or Apple Remote Desktop to log in remotely, but the above command works when I can’t be there to get past the FileVault log in screen and I’m remote and it generates a graphical log in from a remote ssh session.

Once the restart completes, Mail can start. Set it to launch at log in if you wish and you’re set. You don’t need auto log in since this works to make auto log in one time only.