Nevin Raj Victor
Nevin Raj Victor

Reputation: 2974

Unlock the key-chain in mac through python

Is there any way to unlock the key-chain in mac through python. I got it in bash as security unlock-keychain -p $KEYCHAIN_PASSWORD $PATH_TO_KEYCHAIN. But couldnt find a solution for the same in python anywhere. Please help me out.

Upvotes: 0

Views: 911

Answers (1)

MJeffryes
MJeffryes

Reputation: 458

There isn't a Python API for this. Use the subprocess module to call the external program.

import subprocess

cmd = "security unlock-keychain -p".split() 
cmd += [keychain_password, path_to_keychain]
subprocess.call(cmd)

Further reading on subprocess

Upvotes: 2

Related Questions