lastpass / lastpass-cli

LastPass command line interface tool
GNU General Public License v2.0
2.86k stars 291 forks source link

Unable to login using the non-interactive ways #472

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, when trying to login using the non-interactive way : echo 'PASSWORD' | lpass login MYEMAIL it keeps returing me this error : Error: Failed to enter correct password.

CentOS Linux release 7.6.1810 (Core) LastPass CLI v1.3.1

msbit commented 5 years ago

Have you tried setting LPASS_DISABLE_PINENTRY=1 as per: https://github.com/lastpass/lastpass-cli/blob/8d91585219e9e757fae1ced7477d6a3736db4e44/lpass.1.txt#L84-L86

You should be able to run it like:

$ echo 'PASSWORD' | LPASS_DISABLE_PINENTRY=1 lpass login MYEMAIL

or by setting the environment variable for your shell (export LPASS_DISABLE_PINENTRY=1 in ~/.profile or similar).

mattduguid commented 3 years ago

try this Im using it in an automated pipeline with no issue, obviously set your variables and you will need the var that @msbit has already mentioned,

# linux/bash
export LPASS_DISABLE_PINENTRY="1"
LOGGED_IN=$($LPASS_HOME/lpass login "$LASTPASS_USER" <<<"$LASTPASS_PASSWORD")
echo $LOGGED_IN
# windows/powershell
$env:LPASS_DISABLE_PINENTRY = "1"
$LOGGED_IN = echo $LASTPASS_PASSWORD | & lpass login $LASTPASS_USER
Write-Host $LOGGED_IN
thirdender commented 1 year ago

The password I was given included a ! which caused issues inside of double-quotes, which was causing the same Failed to enter correct password error. If you suspect your shell is mangling the password, try passing it to cat and check the output:

cat <<<"$PASSWORD"

See also https://stackoverflow.com/questions/11025114/how-do-i-escape-an-exclamation-mark-in-bash