Use two-factor authentication for security on your Mac and iOS devices
Two-factor authentication is an extra layer of security for your Apple ID designed to ensure that you’re the only one who can access your account—even if someone knows your password.
See the Apple Support article Two-factor authentication for Apple ID.
Turn on two-factor authentication for your Apple ID
You can turn on two-factor authentication while setting up a new Mac, or follow the steps below any time to turn it on in iCloud preferences.
On your Mac, choose Apple menu > System Preferences, then click iCloud.
Click Account Details, then enter your Apple ID password, if asked.
Click Security, click Set Up Two-Factor Authentication, then click Continue.
Answer the verification questions, then click Verify.
Enter your phone number for verification, select a verification method, then click Continue.
When asked, verify your identity with the six-digit verification code sent to your iPhone. You won’t be asked for a verification code again on your Mac unless you sign out of iCloud completely, erase your Mac, or need to change your password for security reasons.
Sign in with two-factor authentication
A verification code is a temporary code sent to your trusted devices or phone number when you sign in to a new device or browser with your Apple ID.
When you’re asked for the verification code, look for a notification at a trusted phone number or on any of your trusted devices.
To send the code to a trusted phone number, click “Didn’t get a verification code?” in the notification, then choose the phone number.
On a trusted device, tap or click Allow to see the code on that device.
Enter the code on your Mac.
Get a verification code on a Mac, even when it’s offline
If you can’t receive a verification code on your phone or trusted devices, or if none of them are available, you can get a verification code in iCloud preferences, even if your Mac is offline.
On your Mac, choose Apple menu > System Preferences, then click iCloud.
Click Account Details, then enter your Apple ID password, if asked.
Click Security.
Click Get Verification Code.
Write down the verification code or enter it in the notification, then click OK.
Add a trusted device
To make a Mac (OS X 10.11 or later) or an iOS device (iOS 9 or later) a trusted device, you must sign in to iCloud using your Apple ID on the Mac or device.
Using a Mac: Choose Apple menu > > System Preferences, click iCloud, enter your Apple ID and password, then click Sign In. Enter the passcode you use to unlock your other trusted Mac or device, then click Continue. Select the iCloud app options you want, then click Next.
Using an IOS device: Tap Settings > your name (at the top of the screen). If you’re using iOS 10.2 or earlier, tap Settings > iCloud. Verify your identity with a six-digit verification code.
If you previously signed in, sign in again.
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.
Add or remove a trusted phone number
You must verify at least one trusted phone number to enroll in two-factor authentication.
On your Mac, choose Apple menu > System Preferences, then click iCloud.
Click Account Details, then enter your Apple ID password, if asked.
Click Security, then do one of the following:
Add a phone number: Click the Add button , enter the phone number and select a verification method, then click Continue.
Remove a phone number: Select the phone number, click the Remove button , then click Remove.
Your trusted phone numbers appear in a list.
Click Done.
View or remove trusted devices
On your Mac, choose Apple menu > System Preferences, then click iCloud.
Click Account Details, then enter your Apple ID password, if asked.
Click Devices, then select a device in the list.
To remove a trusted device, click Remove from Account, then click Remove.
Click Done.
Turn off two-factor authentication
Click Edit in the Security pane, then click Turn Off Two-Factor Authentication.
You can also turn two-factor authentication off and manage your trusted devices and phone numbers by signing in to your Apple ID account page.