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.
To see whether your Apple ID has two-factor authentication turned on, choose Apple menu > System Settings, then click [your name] in the sidebar. Click Password & Security, then turn on Two-Factor Authentication.
You can also turn on two-factor authentication and manage your trusted devices and phone numbers by signing in to your Apple ID account page.
Turn on two-factor authentication
If your account meets all the requirements for two-factor authentication, you’re asked to turn it on when you first use your Mac.
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’re 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
After you enroll in two-factor authentication, 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. 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.
As extra protection for your Apple ID against phishing attacks, you can use a physical security key instead of a verification code. See the Apple Support article About Security Keys for Apple ID.
See the Apple Support article Two-factor authentication for Apple ID.