I'm using the Lastpass CLI (lpass) and want to have it give the passphrase for a private key direct to add-ssh on login as part of .bashrc . the net effect is that I login to Lastpass on when I start the terminal window and then the key is ready to use

triggering login is just:

lpass login user@example.com

Which already works fine and you can print the passphrase of the key using:

lpass show --field=Passphrase  1234

where 1234 is the item id

My current draft is

lpass login user@example.com    

lpass show --field=Passphrase 1234

if [ -z "$SSH_AUTH_SOCK" ] ; then
  eval `ssh-agent -s`


This prints the passphrase to be copied - not ideal - how can I pass this directly?

Edit: I've been looking at using expect - and believe this might work if I can call expect from .bachrc and can pass the out put of the below into a response.

lpass show --field=Passphrase 1234

Is this possible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.