macOS Sierra: two-factor authentication
Two-factor authentication is an extra layer of security for your Apple ID designed to ensure that you’re the only person who can access your account, even if someone knows your password.
Enroll in two-factor authentication
If your account meets all the requirements for two-factor authentication, you are prompted to turn it on when you first use your Mac. You can also turn it on in iCloud preferences. Choose Apple menu > System Preferences, then click iCloud. Sign in to your account if necessary, click Account Details, then click Security.
Important: If you’re using two-step verification, you must turn it off before you can turn on two-factor authentication. To do so, sign in to your Apple ID account page. In the Security section, click Edit, then click Turn Off Two-Step Verification. You’ll be asked to create new security questions and verify your date of birth. You should receive an email confirming that two-step verification for your Apple ID is turned off.
Use two-factor authentication
Once enrolled, when you enter your Apple ID and password for the first time on a new device, you’re asked to verify your identity with a six-digit verification code. This code is displayed automatically on your other devices or sent to a phone number you trust. Just enter the code to sign in and access your information on your new device.
You won’t be asked for a verification code again on that device unless you sign out of iCloud completely, erase your device, or need to change your password for security reasons.
You can manage your trusted devices and phone numbers in iCloud preferences on a trusted Mac, in Settings > iCloud > Apple ID on a trusted iOS device, or by signing in to your Apple ID account page.
For more information, see the Apple Support article Two-factor authentication for Apple ID.