You want to store your recovery codes to 1Password after setting up one-time password but too lazy to add them manually? Here is the script to automatically do that using 1Password CLI.
- First, you need to install 1Password CLI.
- Then store your recovery codes line by line in a file named the item ID you want to add, you can find the ID of the item with this command:
op item list
- Finally, run the script with the recovery code file or a folder contains multiple recovery code files.
Examples:
$ cat ~/Downloads/op/rahzlludgpggjqs6zszgpe34la
6501 5184
3856 9113
2963 2385
0927 3516
5486 2267
$ cat ~/Downloads/op/3afisa8bszydcorcjy3i5wbyaru.txt
szqpf68cf9
7jaaka4zc0
1rd1tjkga7
azzwfw0xnx
89stsj5j1e
3xyv30qr45
pdq9qpvj2j
6236rt7g6t
$ ./op-add-recovery-code.sh ~/Downloads/op
==> Processing '/Users/thanhph111/Downloads/op/rahzlludgpggjqs6zszgpe34la'
Found item 'rahzlludgpggjqs6zszgpe34la' (Instagram), adding recovery code
Added code 1: 6501 5184
Added code 2: 3856 9113
Added code 3: 2963 2385
Added code 4: 0927 3516
Added code 5: 5486 2267
==> Processing '/Users/thanhph111/Downloads/op/3afisa8bszydcorcjy3i5wbyaru.txt'
Found item '3afisa8bszydcorcjy3i5wbyaru' (Firefox), adding recovery code
Added code 1: szqpf68cf9
Added code 2: 7jaaka4zc0
Added code 3: 1rd1tjkga7
Added code 4: azzwfw0xnx
Added code 5: 89stsj5j1e
Added code 6: 3xyv30qr45
Added code 7: pdq9qpvj2j
Added code 8: 6236rt7g6t
Result:
Firefox | |
---|---|