当您在Mac上登录网站、应用程序和无线网络时,您可以选择将用户名和密码保存到名为(Mac)Apple Keychain的集成密码管理系统中。它使用强大的加密保护登录详细信息,并允许您在后续登录尝试中无缝地自动填写密码。但是,尽管安全和方便,您仍会遇到需要备份钥匙串项目的实例。
无论是将登录详细信息传输到第三方密码管理器还是保护它们免受硬件故障或数据损坏,本教程将向您展示几种在Mac上导出或备份(Mac)钥匙串(Keychain)密码的方法。
(Sync Passwords Online Using)使用iCloud钥匙串(Keychain)在线同步密码
如果您在Mac上使用Apple ID,您可以激活一项称为 iCloud钥匙串的功能,以在(Keychain)Apple服务器上创建基于云的密码副本。您还可以使用它在Apple生态系统中的设备(例如 iPhone 和 iPad)之间同步它们。但最重要的是,如果您重新安装 macOS(reinstall macOS)、切换到新 Mac 或重置 Mac 的管理员密码(reset your Mac’s admin password),它可以帮助您恢复登录信息。
但是,iCloud钥匙串(Keychain)并不是一种完美的备份形式。例如,如果您不小心修改或删除了Mac上的密码,您将无法找回密码。更糟糕的是,iCloud 还会将您的更改同步到您的其他Apple设备。但是使用 iCloud钥匙串的好处大于坏处,所以在你的(Keychain)Mac上激活它仍然是一个好主意。
1.在您的 Mac 上打开系统偏好设置应用程序。(System Preferences)
2. 选择Apple ID。
注意(Note):如果您尚未使用Apple ID登录(Apple ID)Mac,请改用使用Apple ID登录(Sign in with Apple ID)选项并输入您的Apple ID凭据。
3.选中钥匙串(Keychain)旁边的框。
4. 输入您的Apple ID密码并选择OK。
5. 输入您的Mac用户帐户密码,然后选择OK。这应该会提示您的Mac将您的密码上传到Apple服务器。
注意:(Note: )要让您的密码显示在另一台 Mac(Mac)上,只需使用您的Apple ID登录并按照上述步骤激活 iCloud钥匙串(Keychain)。在 iOS 和 iPadOS 设备上,前往“设置”(Settings) > “ Apple ID ” > “钥匙串”并打开(Keychain)iCloud 钥匙串(iCloud Keychain)旁边的开关以同步您的登录信息。
使用Safari 密码管理器(Safari Passwords Manager)导出密码
尽管您的Mac配备了一个名为Keychain Access的专用(Keychain Access)Apple 钥匙串(Apple Keychain)管理器,但您不能使用它来备份或导出项目。但是,如果您的Mac运行 macOS Monterey或更高版本,您可以使用 Safari 的内置密码(Passwords)管理器(可让您查看和自动填充存储在默认登录钥匙串上的已保存密码)以CSV 文件格式(CSV file format)保存您的登录信息。
然后,您可以使用CSV文件将密码导入备用密码管理实用程序(1Password、LastPass和Dashlane是Mac 上最好的密码管理器(best password managers for the Mac))或第三方浏览器,例如Google Chrome或Mozilla Firefox。或者,您可以将其保留为备份,并在丢失时将登录详细信息重新添加到默认钥匙串中。
警告: (Warning)Safari生成的纯文本CSV文件不会加密,因此任何人都可以打开并查看其内容。确保(Make)在将文件导入另一个密码管理器后删除该文件或将其存储在安全位置。
1. 打开Safari并选择菜单栏上的Safari >首选项。(Preferences)
2. 切换到密码(Passwords)选项卡。然后,输入 Mac 的管理员密码或使用 Touch ID 验证自己。
3. 选择密码(Passwords)窗口左下角的更多图标(三个点),然后选择(More)导出密码(Export Passwords)选项。
4.在确认弹出窗口中再次选择导出密码。( Export Passwords)
5. 指定CSV文件的保存目的地并选择保存(Save)。
注意(Note):如果您想将密码重新导入Keychain(相同或不同的Mac),请在Safari的密码(Passwords)管理器中选择更多(More)>导入密码( Import Passwords),然后选择CSV文件。
手动备份(Backups)Keychains文件夹(Keychains Folder)
如果您在Mac上打开(Mac)Keychain Access应用程序(转到Launchpad并选择Other > Keychain Access),您会注意到Default Keychains下的两个列表- Login和Local Items / iCloud。这些钥匙串默认存储您的网站、应用程序和 Wi-Fi 密码。此外,您将在Custom Keychains下找到用户生成的钥匙串。
Apple Keychain将所有这些钥匙串作为单独的数据库文件存储在(Apple Keychain)Mac用户帐户的Library目录下名为Keychains的文件夹中。(Keychains)如果您想恢复对钥匙串项目的任何意外更改,您可以选择定期备份文件夹并恢复文件。
注意(Note):进行手动备份的最佳替代方法是在Mac上激活(Mac)Time Machine。它不仅会定期备份您的整个Mac(包括整个Keychains文件夹),而且还可以帮助您方便地恢复文件和文件夹。了解如何在 Mac 上设置(set up)和使用 Time Machine(use Time Machine on your Mac)。
1. 按住 Control 键单击Dock 上的Finder图标,然后选择(Finder)前往(Go)>前往文件夹( Go to Folder)。
2. 输入以下内容并按Enter:
~/Library
3. 将Keychains文件夹复制到其他目录或外部驱动器。
如果您对钥匙串进行了任何意外更改,您可以通过用备份替换以下数据库文件来恢复它们:
登录(Login):替换login-keychain-db文件。
Local Items / iCloud:替换UDiD(唯一设备标识符)子文件夹下的keychain-2.db、keychain-2.db-wal和keychain-2.db-shm文件。(keychain-2.db-shm )
自定义钥匙串(Custom keychain):通过文件名识别和替换自定义钥匙串。
注意(Note):除了自定义钥匙串,将登录或本地Items/iCloud数据库文件复制到另一台 Mac(Mac)将不起作用。
保护您的钥匙串密码
激活 iCloud钥匙串(Keychain)或将密码导出为CSV既快捷又方便。但是,如果您想创建钥匙串的完整备份,请设置Time Machine或手动复制钥匙串(Keychains)文件夹。
How to Export and Backup Keychain Passwords on Mac
When you log in to websitеs, applicatіоns, and wireless networks on your Mac, you can choose to save usernamеs and passwords to an integrated passwоrd management system called Apple Keychain. It protects the login details using robust encryption and lets you seamlessly auto-fill passwords in subsequent sign-in attempts. But despite the security and convenience, you will run into instances that require you to back up keychain items.
Whether that’s to transfer the login details to a third-party password manager or to protect them against hardware failure or data corruption, this tutorial will show you several methods to export or back up Keychain passwords on Mac.
Sync Passwords Online Using iCloud Keychain
If you use an Apple ID on your Mac, you can activate a feature called iCloud Keychain to create a cloud-based copy of your passwords on the Apple servers. You can also use it to sync them across devices within the Apple ecosystem (such as the iPhone and iPad). But most importantly, it helps you restore your login info if you reinstall macOS, switch to a new Mac, or reset your Mac’s admin password.
However, iCloud Keychain is not a perfect form of backup. For example, if you accidentally modify or remove a password on your Mac, you can’t get it back. Worse yet, iCloud will also sync your changes to the rest of your Apple devices. But the advantages of using iCloud Keychain outweigh the cons, so it’s still a good idea to have it active on your Mac.
1. Open the System Preferences app on your Mac.
2. Select Apple ID.
Note: If you’ve yet to sign in to your Mac with an Apple ID, use the Sign in with Apple ID option instead and enter your Apple ID credentials.
3. Check the box next to Keychain.
4. Enter your Apple ID password and select OK.
5. Enter your Mac user account password and select OK. That should prompt your Mac to upload your passwords to the Apple servers.
Note: To get your passwords to show up on another Mac, simply sign in with your Apple ID and follow the steps above to activate iCloud Keychain. On iOS and iPadOS devices, go to Settings > Apple ID > Keychain and turn on the switch next to iCloud Keychain to sync your login info.
Export Passwords Using Safari Passwords Manager
Although your Mac comes with a dedicated Apple Keychain manager called Keychain Access, you can’t use it to back up or export items. But if your Mac runs macOS Monterey or later, you can use Safari’s built-in Passwords manager (which lets you view and autofill saved passwords stored on your default login keychain) to save your login info in the CSV file format.
You can then use the CSV file to import the passwords into an alternative password management utility (1Password, LastPass, and Dashlane are among the best password managers for the Mac) or a third-party browser such as Google Chrome or Mozilla Firefox. Or, you can keep it as a backup and re-add the login details to your default keychain if you lose it.
Warning: The plain-text CSV file that Safari generates will have no encryption, so anyone can be open and view its contents. Make sure to delete the file after importing it to another password manager or store it in a secure location.
1. Open Safari and select Safari > Preferences on the menu bar.
2. Switch to the Passwords tab. Then, enter your Mac’s admin password or authenticate yourself using Touch ID.
3. Select the More icon (three dots) at the bottom-left corner of the Passwords window and pick the Export Passwords option.
4. Select Export Passwords again on the confirmation pop-up.
5. Specify a save destination for the CSV file and select Save.
Note: If you want to re-import the passwords to Keychain (into the same or a different Mac), select More > Import Passwords in the Passwords manager in Safari and select the CSV file.
Take Manual Backups of the Keychains Folder
If you open the Keychain Access app on your Mac (go to Launchpad and select Other > Keychain Access), you’ll notice two listings under Default Keychains—Login and Local Items/iCloud. These keychains store your website, app, and Wi-Fi passwords by default. Additionally, you’ll find user-generated keychains under Custom Keychains.
Apple Keychain stores all these keychains as separate database files in a folder called Keychains under the Library directory of your Mac user account. You can choose to make periodic backups of the folder and restore the files if you want to revert any accidental changes to your keychain items.
Note: The best alternative to taking manual backups is to activate Time Machine on your Mac. Not only does it then back up your entire Mac periodically (including the entire Keychains folder), but it also helps you conveniently restore files and folders. Learn how to set up and use Time Machine on your Mac.
1. Control-click the Finder icon on the Dock and select Go > Go to Folder.
2. Type in the following and press Enter:
~/Library
3. Copy the Keychains folder to a different directory or an external drive.
If you make any accidental changes to your keychains, you can restore them by replacing the following database files with your backups:
Login: Replace the login-keychain-db file.
Local Items/iCloud: Replace the keychain-2.db, keychain-2.db-wal, and keychain-2.db-shm files under the UDiD (unique device identifier) sub-folder.
Custom keychain: Identify and replace the custom keychain by filename.
Note: Custom keychains aside, copying the Login or the Local Items/iCloud database files to another Mac will not work.
Protect Your Keychain Passwords
Activating iCloud Keychain or exporting passwords to CSV is quick and convenient. But If you want to create full backups of your keychains, set up Time Machine or make manual copies of the Keychains folder.