lastpass / lastpass-cli

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

Unable to delete form fields #392

Open waterkip opened 6 years ago

waterkip commented 6 years ago

Have a site that looks something like this:

Username: bar
Password: foo
URL: https://foo.bar
foo: bar

Try to delete foo: bar by running lpass edit $site and remove the foo: bar line, save and commit Run lpass show $site

You'll see that foo: bar is still available

leftiness commented 6 years ago

Same.

Username: foo
USERNAME: foo

Had to remove the extra fields using the GUI. Idk how they got there in the first place.

noperator commented 6 years ago

This is still an issue. Would love to see this fixed.

9oOzv commented 4 years ago

Hoping for a fix as well

noperator commented 4 years ago

Wow, I forgot that this issue was still open. Since lpass doesn't let you delete some fields from an existing entry (e.g., foo in the original comment on this issue), I wrote a Bash function that duplicates the entry of interest while only carrying forward the URL, username, and password fields—effectively stripping away extraneous fields like foo:

# Usage: lpc <OLD_ID> <NEW_NAME>
lpc () { 
    lpass show -Gx "$1" | grep -E "^(Username|Password|URL):" | lpass add --non-interactive "$2";
    lpass show -Gx "$2"
}

After verifying that the new duplicated entry looks right, you can manually delete the old entry. Here's an example of how this works:

$ lpass show -x github.com
github.com [id: 1234567890]
  URL: https://github.com
  Username: noperator
  Password: notreallymypassword
  foo: iwanttoremovethisfield   # We'll remove this field.

$ lpc 1234567890 github.com     # Copy ID "1234567890" to new entry named "github.com".
github.com [id: 1234567890]     # Old entry.
  URL: https://github.com
  Username: noperator
  Password: notreallymypassword
  foo: iwanttoremovethisfield
github.com [id: 2345678901]     # New entry without "foo" field.
  URL: https://github.com
  Username: noperator
  Password: notreallymypassword

$ lpass rm 1234567890           # New entry looks good, so remove old entry.

It often takes a moment for lpass to assign an identifier to the new entry, so it'll show up as [id: 0] right after the lpc function returns. Just give it a moment and run another lpass show -x <NAME> until you see an ID on your new entry.

9oOzv commented 4 years ago

I guess you can use something like that as a workaround.

The function does not seem to copy over notes, which should be trivial to add. Also worth noting is that you will probably lose password history doing that.