如何自动化 Lastpass CLI 登录过程

How to automate the Lastpass CLI login process

我想知道是否有人成功地自动化了 LastPass CLI 登录过程。我似乎无法绕过密码提示,我需要将其自动化以使其有用。

我试过像

这样的命令
echo <password> | lpass login <username>

yes <password> | lpass login <username>

我一直收到输出说密码不正确。有人自动化了吗?

谢谢!

您可能需要禁用 pinetry 密码提示,以便 lpass 从标准输入读取您的密码。

正如手册页所说:

If pinentry program is unavailable, or if the LPASS_DISABLE_PINENTRY environment variable is set to 1, passwords will be read from standard input and a prompt will be displayed on standard error.

意思:如果你运行这样应该可以工作:

echo <password> | LPASS_DISABLE_PINENTRY=1 lpass login <username>

或者只需为您的 shell 设置环境变量(export LPASS_DISABLE_PINENTRY=1 在您的 ~/.profile 或类似的环境中)