iCloud Keychain is Apple's approach to managing passwords effortlessly across both iOS and OS X. After you've set it up, all your passwords and credit card information is immediately synced securely across your devices. When adding a new device or replacing one, you'll need to verify with either a security code or phone number. So what if you forget or lose your security code? As it turns out, all is not lost. As long as you know your iCloud password and you're running iOS 8 or higher, you can easily reset it!
How to reset your iCloud Keychain security code in iOS 8
Launch the Settings app on your iPhone or iPad running iOS 8 or higher.
Tap on iCloud.
Tap on Keychain.
Enter your iCloud password if prompted.
Tap on Advanced.
Tap on Change Security Code.
Type in a new code.
You can also tap on Advanced Options in order to choose a more complex code or have one generated for you if you choose.