### Build and Install Documentation Source: https://github.com/lastpass/lastpass-cli/blob/master/README.md Uses the make utility to compile and install the documentation files for the lpass command. ```bash sudo make install-doc ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/lastpass/lastpass-cli/blob/master/README.md Installs the required asciidoc and xsltproc tools on Debian-based systems to enable documentation building. ```bash sudo apt-get install asciidoc xsltproc ``` -------------------------------- ### Bash Completion Installation - CMake Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Handles the installation of bash completion scripts for the LastPass CLI. It checks if bash completion is found, adjusts the installation directory based on the CMAKE_INSTALL_PREFIX to fix issue GH-478, and installs the completion script to the appropriate destination. ```cmake if(BASH_COMPLETION_FOUND) pkg_get_variable(BASH_COMPLETION_COMPLETIONSDIR bash-completion completionsdir) # Fix GH-478 if(NOT "${BASH_COMPLETION_PREFIX}" STREQUAL "${CMAKE_INSTALL_PREFIX}") string(REGEX REPLACE "^${BASH_COMPLETION_PREFIX}" "${CMAKE_INSTALL_PREFIX}" COMP_DIR ${BASH_COMPLETION_COMPLETIONSDIR}) set(BASH_COMPLETION_COMPLETIONSDIR ${COMP_DIR}) unset(COMP_DIR) endif() install(FILES contrib/lpass_bash_completion DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR} RENAME lpass) endif() ``` -------------------------------- ### Generate a New Password (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This example shows how to generate a new password for a specific entry (e.g., 'work/email') with a specified length (20 characters). ```shell $ lpass generate work/email 20 ``` -------------------------------- ### lpass Subcommand Examples Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This section provides examples of common lpass subcommands for managing LastPass entries. These commands cover actions like logging in, logging out, showing, listing, moving, adding, editing, generating, duplicating, removing, and checking the status of LastPass entries. ```bash lpass login [--trust] [--plaintext-key [--force, -f]] [--color=auto|never|always] USERNAME lpass logout [--force, -f] [--color=auto|never|always] lpass passwd lpass show [--sync=auto|now|no] [--clip, -c] [--quiet, -q] [--expand-multi, -x] [--json, -j] [--all|--username|--password|--url|--notes|--field=FIELD|--id|--name|--attach=ATTACHID] [--basic-regexp, -G|--fixed-strings, -F] [--color=auto|never|always] {NAME|UNIQUEID}* lpass ls [--sync=auto|now|no] [--long, -l] [-m] [-u] [--color=auto|never|always] [GROUP] lpass mv [--sync=auto|now|no] [--color=auto|never|always] {UNIQUENAME|UNIQUEID} GROUP lpass add [--sync=auto|now|no] [--non-interactive] {--name|--username, -u|--password, -p|--url|--notes|--field=FIELD|--note-type=NOTETYPE} [--color=auto|never|always] {NAME|UNIQUEID} lpass edit [--sync=auto|now|no] [--non-interactive] {--name|--username, -u|--password, -p|--url|--notes|--field=FIELD} [--color=auto|never|always] {NAME|UNIQUEID} lpass generate [--sync=auto|now|no] [--clip, -c] [--username=USERNAME] [--url=URL] [--no-symbols] [--color=auto|never|always] {NAME|UNIQUEID} LENGTH lpass duplicate [--sync=auto|now|no] [--color=auto|never|always] {UNIQUENAME|UNIQUEID} lpass rm [--sync=auto|now|no] [--color=auto|never|always] {UNIQUENAME|UNIQUEID} lpass status [--quiet, -q] [--color=auto|never|always] ``` -------------------------------- ### Add a New Secure Note (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This example demonstrates adding a new secure note with a specific type (e.g., 'ssn'). It opens an editor for you to fill in the note's content. ```shell $ lpass add --note-type=ssn info/my-ssn ``` -------------------------------- ### Login to LastPass CLI (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This is a basic example of how to log in to your LastPass account using the CLI. It requires your email address. ```shell $ lpass login user@example.com ``` -------------------------------- ### Automate LastPass with Scripts Source: https://context7.com/lastpass/lastpass-cli/llms.txt Examples of using LastPass CLI in shell scripts for tasks like batch password retrieval, automated backups, and SSH authentication. ```bash PASSWORD=$(lpass show --password mysite.com) if ! lpass status -q; then echo "Please login first: lpass login user@example.com" exit 1 fi for site in github.com gitlab.com bitbucket.org; do echo "$site: $(lpass show -p $site 2>/dev/null || echo 'not found')" done lpass sync && lpass export | gpg -e -r backup@example.com > vault-$(date +%Y%m%d).csv.gpg export SSH_ASKPASS_REQUIRE=prefer export SSH_ASKPASS="lpass show --password ssh-key-passphrase" ssh-add ~/.ssh/id_rsa ``` -------------------------------- ### Custom Targets for Documentation and Uninstallation - CMake Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Defines custom targets for generating documentation (man pages and HTML) and for handling uninstallation. These targets depend on the custom commands defined earlier and use CMake's scripting capabilities to manage documentation installation and removal. ```cmake add_custom_target(doc-man DEPENDS lpass.1) add_custom_target(doc-html DEPENDS lpass.1.html) # See https://cmake.org/pipermail/cmake/2009-January/026520.html add_custom_target(install-doc COMMAND ${CMAKE_COMMAND} -DMANDIR=${CMAKE_INSTALL_FULL_MANDIR} -P ${CMAKE_SOURCE_DIR}/cmake_extras/install_doc.cmake DEPENDS doc-man) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -DPROJECT_NAME=${PROJECT_NAME} -DMANDIR=${CMAKE_INSTALL_FULL_MANDIR} -P ${CMAKE_SOURCE_DIR}/cmake_extras/uninstall.cmake) ``` -------------------------------- ### Configure LastPass CLI Command Aliases Source: https://github.com/lastpass/lastpass-cli/blob/master/CHANGELOG.md Create aliases for LastPass CLI commands to set default flags or nicknames. This example enables regex matching by default for the show command. ```bash mkdir -p ~/.lpass echo 'show -G' > ~/.lpass/alias.show ``` -------------------------------- ### Add Account Non-interactively (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This example shows how to add a new account to LastPass non-interactively using a pipe to feed account details. It's useful for scripting and automation. ```shell printf "Username: wizard97\nPassword: vJwhFfBBtn8hj4" | \ lpass add Facebook --non-interactive ``` -------------------------------- ### Configure 'ls' Command to Never Use Color (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This example demonstrates how to create an alias file to configure a specific LastPass command ('ls' in this case) to disable color output. This ensures consistent output when piping or redirecting. ```shell echo 'ls --color=never' > ~/.config/lpass/alias.ls ``` -------------------------------- ### Resolve pkg-config Variables for Dependencies Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Provides a fallback mechanism for pkg_get_variable on older CMake versions. It ensures that bash-completion paths are correctly identified regardless of the installed CMake version. ```cmake if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.4) function(pkg_get_variable _output_name _pkg _name) execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg} OUTPUT_VARIABLE _pkg_result OUTPUT_STRIP_TRAILING_WHITESPACE) set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable ${_name} of ${_pkg}") endfunction() pkg_get_variable(BASH_COMPLETION_PREFIX bash-completion prefix) if(BASH_COMPLETION_PREFIX) set(BASH_COMPLETION_FOUND TRUE) endif() else() include(FindPkgConfig) pkg_search_module(BASH_COMPLETION bash-completion) endif() ``` -------------------------------- ### Configure macOS Homebrew Paths Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Detects Homebrew installations on macOS to locate pkg-config files for dependencies like curl and openssl. It dynamically updates the PKG_CONFIG_PATH environment variable to ensure correct library linking. ```cmake if(APPLE) find_program(BREW_INSTALLED BREW) if(BREW_INSTALLED) function(get_brew_packageconfig_path _package_name _output_variable) # Logic to find cellar and prefix paths for brew packages # ... (omitted for brevity) endfunction() get_brew_packageconfig_path("curl" BREW_CURL) get_brew_packageconfig_path("openssl" BREW_OPENSSL) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl:${BREW_CURL}:${BREW_OPENSSL}") endif() endif() ``` -------------------------------- ### Login to LastPass CLI Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Initializes a local cache and configuration folder, then attempts to authenticate with LastPass servers. Supports interactive prompting for credentials and multifactor authentication. The '--trust' option can be used to skip multifactor authentication on subsequent logins. ```bash lpass login # or for interactive prompt: lpass login ``` -------------------------------- ### Build Test Executable - CMake Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Sets up a separate executable for running tests ('lpass-test'). It includes test-specific source files, defines the 'TEST_BUILD' preprocessor macro, links the same core libraries as the main executable, and conditionally links '-lkvm' on OpenBSD. ```cmake file(GLOB LPTEST_SOURCES test/*.c *.c) add_executable(lpass-test EXCLUDE_FROM_ALL ${PROJECT_HEADERS} ${LPTEST_SOURCES}) set_target_properties(lpass-test PROPERTIES C_STANDARD 99 COMPILE_FLAGS "${PROJECT_FLAGS} -DTEST_BUILD" COMPILE_DEFINITIONS ${PROJECT_DEFINITIONS} ) target_link_libraries(lpass-test ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES}) if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") target_link_libraries(lpass-test "-lkvm") endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") ``` -------------------------------- ### LastPass CLI Formatting Placeholders Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Provides printf-style format string placeholders for customizing output in 'show' and 'ls' commands. Includes placeholders for account ID, name, user, password, modification time, last touch time, share name, group name, URL, field name, and field value. ```bash # Example: Show full path to an account lpass ls --format="%/as%/ag%an" # Available placeholders: # %ai: account id # %an: account name # %aN: account name including path # %au: account user # %ap: account password # %am: account modification time # %aU: account last touch time # %as: account share name # %ag: account group name # %al: account URL # %fn: field name (for 'show') # %fv: field value (for 'show') ``` -------------------------------- ### Managing Credentials Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for adding new accounts and secure notes to your vault. ```APIDOC ## Managing Credentials ### `lpass add` Creates a new account or secure note in the vault. #### Method `POST` (conceptual) #### Endpoint `/vault/accounts` or `/vault/notes` (conceptual) #### Parameters - `--note-type` - Optional - Specifies the type of secure note (e.g., `--note-type=ssn`). - `--non-interactive` - Optional - Adds account non-interactively using piped input. #### Request Example ```bash # Add new account interactively (opens editor) lpass add work/email # Add with specific username and password non-interactively printf "Username: myuser\nPassword: mypassword123" | lpass add work/email --non-interactive # Add with URL non-interactively printf "Username: myuser\nPassword: secret\nURL: https://example.com" | \ lpass add example-login --non-interactive # Add a secure note with template lpass add --note-type=ssn info/my-ssn ``` #### Request Body Example (for non-interactive add) ``` Username: myuser Password: mypassword123 URL: https://example.com Notes: Some additional notes. ``` ``` -------------------------------- ### Build Main Executable - CMake Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Configures the main LastPass CLI executable, setting C standard, compile flags, definitions, and linking necessary libraries like libxml2, OpenSSL, and libcurl. It also includes conditional linking for OpenBSD and custom commands for generating man pages and HTML documentation. ```cmake add_executable(${PROJECT_NAME} ${PROJECT_HEADERS} ${PROJECT_SOURCES}) set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99 COMPILE_FLAGS ${PROJECT_FLAGS} COMPILE_DEFINITIONS ${PROJECT_DEFINITIONS} ) target_link_libraries(${PROJECT_NAME} ${LIBXML2_LIBRARIES} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES}) if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") target_link_libraries(${PROJECT_NAME} "-lkvm") endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") add_custom_command(OUTPUT lpass.1 DEPENDS ${CMAKE_SOURCE_DIR}/lpass.1.txt COMMAND a2x -D ./ --no-xmllint -f manpage ${CMAKE_SOURCE_DIR}/lpass.1.txt) add_custom_command(OUTPUT lpass.1.html DEPENDS ${CMAKE_SOURCE_DIR}/lpass.1.txt COMMAND asciidoc -b html5 -a data-uri -a icons -a toc2 -o lpass.1.html ${CMAKE_SOURCE_DIR}/lpass.1.txt) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Accessing the Manpage Source: https://github.com/lastpass/lastpass-cli/blob/master/README.md Displays the manual page for the lpass command to provide usage information and command references. ```bash man lpass ``` -------------------------------- ### Viewing Credentials Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for displaying account information, including passwords, usernames, and notes. ```APIDOC ## Viewing Credentials ### `lpass show` Displays account information including passwords, usernames, URLs, notes, and custom fields. Supports exact matching, regex, and substring searches. #### Method `GET` (conceptual) #### Endpoint `/vault/accounts/{id}` or `/vault/accounts?search={query}` (conceptual) #### Parameters - `password` (`-p`) - Optional - Show only the password. - `username` - Optional - Show only the username. - `clip` (`-c`) - Optional - Copy the specified field to the clipboard. - `field` - Optional - Show a specific custom field (e.g., `--field=pin`). - `id` - Optional - Show account by unique ID. - `basic-regexp` (`-G`) - Optional - Search using a case-insensitive regular expression. - `fixed-strings` (`-F`) - Optional - Search using a fixed substring. - `expand-multi` (`-x`) - Optional - Show multiple matches when search returns more than one. - `json` - Optional - Output as JSON. - `quiet` (`-q`) - Optional - Suppress prompts for scripting. - `sync` - Optional - Force sync before showing (e.g., `--sync=now`). - `attach` - Optional - Show attachment from a secure note (e.g., `--attach att-1426405543365295118-94690`). - `format` - Optional - Custom format output with placeholders (e.g., `--format="%an: %au / %ap"`). #### Request Example ```bash lpass show mysite.com lpass show --password mysite.com lpass show -p mysite.com lpass show --clip --password mysite.com lpass show -cp mysite.com lpass show --field=pin mysite.com lpass show --id 140613939481239829 lpass show --basic-regexp "mail.*" lpass show -G "mail.*" lpass show --fixed-strings "gmail" lpass show -F "gmail" lpass show --expand-multi --password "mail" lpass show -xp "mail" lpass show --json mysite.com lpass show --quiet --password mysite.com lpass show -qp mysite.com lpass show --sync=now mysite.com lpass show my-secure-note --attach att-1426405543365295118-94690 lpass show --format="%an: %au / %ap" mysite.com ``` #### Response Example (JSON output) ```json { "id": "1234567890", "name": "mysite.com", "url": "https://mysite.com", "username": "user@example.com", "password": "s3cr3tP@ssw0rd", "extra": { "pin": "1234" }, "notes": "Some notes here.", "created": "2023-01-01T10:00:00Z", "updated": "2023-01-01T10:00:00Z" } ``` ### `lpass ls` Lists accounts organized by groups in a tree structure. #### Method `GET` (conceptual) #### Endpoint `/vault/groups` or `/vault/groups/{group_id}` (conceptual) #### Parameters - `long` (`-l`) - Optional - List with modification times. - `use-time` (`-u`) - Optional - List with last-use times. - `sync` - Optional - Force sync before listing (e.g., `--sync=now`). - `color` - Optional - Disable colored output (e.g., `--color=never`). - `format` - Optional - Custom format output (e.g., `--format="%/as%/ag%an"`). #### Request Example ```bash lpass ls lpass ls work lpass ls --long lpass ls -l lpass ls -u lpass ls -l -m lpass ls "Personal\Banking" lpass ls --format="%/as%/ag%an" lpass ls --sync=now lpass ls --color=never ``` #### Response Example ``` - Personal - Email - Gmail (user@gmail.com) - Work - Company VPN (vpnuser) - Secure Notes - My SSN ``` ``` -------------------------------- ### lpass Synchronization Options Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This section details the '--sync' options for lpass, which control how and when operations synchronize with the LastPass server. Options include 'now' for immediate synchronization, 'auto' for background synchronization, and 'no' to prevent server interaction unless an upload queue is active. ```bash lpass [--sync=auto|now|no] ... ``` -------------------------------- ### List Entries in a Folder (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command lists the entries within a specified folder (e.g., 'work'). It displays the entry name and its ID. ```shell $ lpass ls work ``` -------------------------------- ### Configure LastPass Environment Variables Source: https://context7.com/lastpass/lastpass-cli/llms.txt Setting up environment variables to customize the behavior of the LastPass CLI, such as agent timeouts, pinentry paths, and logging levels. ```bash export LPASS_HOME=~/.lpass export LPASS_AGENT_TIMEOUT=28800 export LPASS_AGENT_DISABLE=1 export LPASS_AUTO_SYNC_TIME=10 export LPASS_PINENTRY=/usr/bin/pinentry-gtk export LPASS_DISABLE_PINENTRY=1 export LPASS_ASKPASS=/usr/bin/ssh-askpass export LPASS_CLIPBOARD_COMMAND="xclip -selection clipboard" export LPASS_LOG_LEVEL=7 ``` -------------------------------- ### Create LastPass Command Aliases Source: https://context7.com/lastpass/lastpass-cli/llms.txt Defining custom aliases to simplify common lpass commands by storing them in the configuration directory. ```bash echo 'ls --color=never' > ~/.config/lpass/alias.ls echo 'show --password -c' > ~/.config/lpass/alias.passclip echo 'show -G' > ~/.config/lpass/alias.show echo 'ls -l' > ~/.config/lpass/alias.ll ``` -------------------------------- ### Show Password for an Entry (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command retrieves and displays the password for a specific entry (e.g., 'email'). The '-p' flag ensures only the password is shown. ```shell $ lpass show -p email ``` -------------------------------- ### Show a Secure Note (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command displays the content of a secure note, including any associated fields like 'Number', 'Name', 'NoteType', and 'Notes'. ```shell $ lpass show my-ssn ``` -------------------------------- ### lpass Password Entry Methods Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This section describes how lpass handles password input, prioritizing the 'pinentry' program if available. It also covers fallback mechanisms using standard input when 'pinentry' is unavailable or disabled via 'LPASS_DISABLE_PINENTRY', and the use of custom 'LPASS_ASKPASS' scripts. ```bash # Example of a custom LPASS_ASKPASS script: #!/bin/bash echo -n "$*: " >/dev/stderr stty -echo read password stty echo echo "$password" ``` -------------------------------- ### View LastPass Credentials Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to display account information, including passwords, usernames, URLs, and custom fields. Supports various search methods, output formats (including JSON), and clipboard integration. ```bash lpass show mysite.com lpass show --password mysite.com lpass show -p mysite.com lpass show --username mysite.com lpass show --clip --password mysite.com lpass show -cp mysite.com lpass show --field=pin mysite.com lpass show --id 140613939481239829 lpass show --basic-regexp "mail.*" lpass show -G "mail.*" lpass show --fixed-strings "gmail" lpass show -F "gmail" lpass show --expand-multi --password "mail" lpass show -xp "mail" lpass show --json mysite.com lpass show --quiet --password mysite.com lpass show -qp mysite.com lpass show --sync=now mysite.com lpass show my-secure-note --attach att-1426405543365295118-94690 lpass show --format="%an: %au / %ap" mysite.com ``` -------------------------------- ### Configure CMake Version and Project Requirements Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Sets the minimum required CMake version based on the host environment and initializes the project name. It ensures compatibility by handling legacy CMake versions for older systems. ```cmake if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.1) set(CMAKE_LEGACY_CYGWIN_WIN32 0) cmake_minimum_required(VERSION 2.8) else() cmake_minimum_required(VERSION 3.1) endif() project(lpass) include(GNUInstallDirs) find_package(PkgConfig REQUIRED) ``` -------------------------------- ### Authentication Commands Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for logging in, logging out, checking status, and changing your master password. ```APIDOC ## Authentication Commands ### `lpass login` Authenticates with LastPass servers and initializes a local encrypted cache. The agent process spawns in the background for subsequent operations. Use `--trust` to remember multifactor authentication for future logins. #### Method `POST` (conceptual, as it's a CLI command) #### Endpoint `/login` (conceptual) #### Parameters - `--trust` - Optional - Enables trusting multifactor authentication for future logins. - `--plaintext-key` - Optional - Uses plaintext key storage (use with caution). - `--force` - Optional - Forces plaintext key without confirmation. #### Request Example ```bash lpass login user@example.com lpass login --trust user@example.com lpass login --plaintext-key user@example.com lpass login --plaintext-key --force user@example.com ``` ### `lpass logout` Removes local cache and encryption keys. Prompts for confirmation unless `--force` is specified. #### Method `POST` (conceptual) #### Endpoint `/logout` (conceptual) #### Parameters - `--force` - Optional - Forces logout without confirmation. #### Request Example ```bash lpass logout lpass logout --force ``` ### `lpass status` Shows current login status and whether the agent is running. #### Method `GET` (conceptual) #### Endpoint `/status` (conceptual) #### Parameters - `--quiet` - Optional - Returns exit code only (0=logged in, 1=not logged in). #### Request Example ```bash lpass status lpass status --quiet ``` #### Response Example (when logged in) ``` Logged in as user@example.com. ``` ### `lpass passwd` Changes your LastPass master password by re-encrypting all records with a newly derived key. #### Method `POST` (conceptual) #### Endpoint `/passwd` (conceptual) #### Request Example ```bash lpass passwd ``` ``` -------------------------------- ### lpass add Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for adding new accounts and secure notes to your LastPass vault. ```APIDOC ## lpass add ### Description Commands for adding new accounts and secure notes to your LastPass vault. ### Examples ```bash # Add secure note with specific field lpass add --notes "my notes" my-note-name --non-interactive # Add custom field lpass add --field=pin work/atm-card --non-interactive # List available secure note types lpass add --note-type=invalid foo # Shows: Invalid note type, valid values: address, amex, credit, database, ... ``` ``` -------------------------------- ### lpass sync Source: https://context7.com/lastpass/lastpass-cli/llms.txt Forces synchronization of local cache with LastPass servers. ```APIDOC ## lpass sync ### Description Forces synchronization of local cache with LastPass servers. ### Examples ```bash # Sync in foreground (wait for completion) lpass sync # Sync in background lpass sync --background lpass sync -b ``` ``` -------------------------------- ### Manage Shared Folders Source: https://context7.com/lastpass/lastpass-cli/llms.txt Administrative commands for shared folder lifecycle management, including creation, removal, and granular user permission control. ```bash lpass share create "Team-Passwords" lpass share useradd --read-only=true --admin=false "Team-Passwords" colleague@example.com lpass share usermod --admin=true "Team-Passwords" colleague@example.com ``` -------------------------------- ### Display Secure Note Attachment to Standard Output (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command displays the binary content of a secure note attachment directly to standard output without prompting. The '--quiet' flag suppresses interactive prompts. ```shell $ lpass show my-secure-note --attach att-1426405543365295118-94690 --quiet ``` -------------------------------- ### Display Secure Note Attachment (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command displays information about a secure note attachment, including its filename and ID. It prompts the user whether to print or save binary data. ```shell $ lpass show my-secure-note --attach att-1426405543365295118-94690 ``` -------------------------------- ### Show LastPass Entry Details Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Displays a password or selected field for a given site. Supports exact name matching, substring matching ('--fixed-strings', '-F'), and case-insensitive regular expression matching ('--basic-regexp', '-G'). Can expand multiple matches with '--expand-multi' ('-x'). Output can be formatted as JSON. ```bash lpass show [--fixed-strings | -F] [--basic-regexp | -G] [--expand-multi | -x] [--json] [--format=FORMAT] ``` -------------------------------- ### Define Tests - CMake Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Enables testing and defines individual test cases for the LastPass CLI. Each 'add_test' command specifies a test name and the executable to run, along with any necessary arguments, covering various functionalities like login, adding/editing entries, and exporting data. ```cmake enable_testing() add_test(test_login ${CMAKE_SOURCE_DIR}/test/tests test_login) add_test(test_login_wrong_pw_should_fail ${CMAKE_SOURCE_DIR}/test/tests test_login_wrong_pw_should_fail) add_test(test_add_account ${CMAKE_SOURCE_DIR}/test/tests test_add_account) add_test(test_add_note ${CMAKE_SOURCE_DIR}/test/tests test_add_note) add_test(test_add_note_with_field ${CMAKE_SOURCE_DIR}/test/tests test_add_note_with_field) add_test(test_add_site_note ${CMAKE_SOURCE_DIR}/test/tests test_add_site_note) add_test(test_add_ssn_name ${CMAKE_SOURCE_DIR}/test/tests test_add_ssn_name) add_test(test_add_ssh_key ${CMAKE_SOURCE_DIR}/test/tests test_add_ssh_key) add_test(test_edit_ssh_key ${CMAKE_SOURCE_DIR}/test/tests test_edit_ssh_key) add_test(test_edit_username ${CMAKE_SOURCE_DIR}/test/tests test_edit_username) add_test(test_edit_field ${CMAKE_SOURCE_DIR}/test/tests test_edit_field) add_test(test_edit_reprompt ${CMAKE_SOURCE_DIR}/test/tests test_edit_reprompt) add_test(test_duplicate ${CMAKE_SOURCE_DIR}/test/tests test_duplicate) add_test(test_generate ${CMAKE_SOURCE_DIR}/test/tests test_generate) add_test(test_show ${CMAKE_SOURCE_DIR}/test/tests test_show) add_test(test_show_json ${CMAKE_SOURCE_DIR}/test/tests test_show_json) add_test(test_show_note ${CMAKE_SOURCE_DIR}/test/tests test_show_note) add_test(test_show_reprompt ${CMAKE_SOURCE_DIR}/test/tests test_show_reprompt) add_test(test_ls ${CMAKE_SOURCE_DIR}/test/tests test_ls) add_test(test_export ${CMAKE_SOURCE_DIR}/test/tests test_export) add_test(test_export_extended ${CMAKE_SOURCE_DIR}/test/tests test_export_extended) ``` -------------------------------- ### Define Project Compilation Flags and Sources Source: https://github.com/lastpass/lastpass-cli/blob/master/CMakeLists.txt Configures project-wide compiler flags, includes necessary libraries (LibXml2, OpenSSL, CURL), and gathers source files for the build process. ```cmake find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIR}) find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIR}) file(GLOB PROJECT_HEADERS *.h version.h) file(GLOB PROJECT_SOURCES *.c) set(PROJECT_FLAGS "-std=gnu99 -pedantic -Wall -Wextra -Wno-language-extension-token") ``` -------------------------------- ### Create Alias for Copying Password to Clipboard (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This snippet demonstrates how to create a shell alias for the 'lpass show' command to automatically copy a password to the clipboard. It utilizes the '-c' option for clipboard integration. ```shell echo 'show --password -c' > ~/.config/lpass/alias.passclip ``` -------------------------------- ### Manage LastPass Shared Folders Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Commands for manipulating shared folders, including listing users ('userls'), adding users ('useradd'), modifying user permissions ('usermod'), deleting users ('userdel'), creating shared folders ('create'), and removing shared folders ('rm'). ```bash lpass share userls lpass share useradd lpass share usermod lpass share userdel lpass share create lpass share rm ``` -------------------------------- ### lpass import Source: https://context7.com/lastpass/lastpass-cli/llms.txt Imports accounts from a CSV file. ```APIDOC ## lpass import ### Description Imports accounts from a CSV file. ### Examples ```bash # Import from file lpass import backup.csv # Import from stdin cat backup.csv | lpass import # Import keeping duplicate entries lpass import --keep-dupes backup.csv # Import GPG-encrypted backup gpg -d backup.csv.gpg | lpass import ``` ``` -------------------------------- ### lpass generate Source: https://context7.com/lastpass/lastpass-cli/llms.txt Generates a random password and saves it to a new or existing account. ```APIDOC ## lpass generate ### Description Generates a random password and saves it to a new or existing account. ### Examples ```bash # Generate 20-character password for new account lpass generate work/email 20 # Output: G ``` -------------------------------- ### lpass Sync Command Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt The 'lpass sync' command explicitly forces a synchronization of the local cache with LastPass servers. It will not exit until synchronization is complete or an error occurs. The '--background' option allows the synchronization to occur in a daemonized process. ```bash lpass sync [--background, -b] [--color=auto|never|always] ``` -------------------------------- ### lpass duplicate Source: https://context7.com/lastpass/lastpass-cli/llms.txt Creates a copy of an existing account with a new unique ID. ```APIDOC ## lpass duplicate ### Description Creates a copy of an existing account with a new unique ID. ### Examples ```bash # Duplicate an account lpass duplicate mysite.com # Duplicate by unique ID lpass duplicate 140613939481239829 # Duplicate with sync lpass duplicate --sync=now mysite.com ``` ``` -------------------------------- ### Authenticate with LastPass CLI Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to log in to and log out of your LastPass account. The login command initializes a local cache and can optionally trust MFA devices. The logout command clears local data. ```bash lpass login user@example.com lpass login --trust user@example.com lpass login --plaintext-key user@example.com lpass login --plaintext-key --force user@example.com lpass logout lpass logout --force ``` -------------------------------- ### Copy Password to Clipboard (Shell) Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt This command retrieves the password for a specific entry (e.g., 'email') and copies it directly to the system clipboard using the '-c' flag. ```shell $ lpass show -cp email ``` -------------------------------- ### Enable Bash Tab Completion Source: https://github.com/lastpass/lastpass-cli/blob/master/CHANGELOG.md Enable tab completion for the LastPass CLI in Bash by sourcing the provided completion script in your shell configuration file. ```bash source contrib/lpass_bash_completion ``` -------------------------------- ### List LastPass Accounts Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to list accounts in your vault, organized by groups in a tree structure. Supports options for displaying modification times, last-use times, and custom formatting. ```bash lpass ls lpass ls work lpass ls --long lpass ls -l lpass ls -u lpass ls -l -m lpass ls "Personal\Banking" lpass ls --format="%/as%/ag%an" lpass ls --sync=now lpass ls --color=never ``` -------------------------------- ### lpass mv Source: https://context7.com/lastpass/lastpass-cli/llms.txt Moves an account to a different group or shared folder. ```APIDOC ## lpass mv ### Description Moves an account to a different group or shared folder. ### Examples ```bash # Move account to a group lpass mv mysite.com Personal # Move to subfolder lpass mv mysite.com "Personal\Banking" # Move to shared folder lpass mv mysite.com "Shared-Work" # Move by unique ID lpass mv 140613939481239829 Archive ``` ``` -------------------------------- ### Synchronize Vault Cache Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to force synchronization between the local cache and the LastPass servers, available in foreground or background modes. ```bash lpass sync lpass sync --background ``` -------------------------------- ### Shared Folder Commands Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for managing shared folders within LastPass. ```APIDOC ## Shared Folder Commands ### lpass share create #### Description Creates a new shared folder (requires enterprise or premium account). #### Example ```bash # Create a shared folder lpass share create "Team-Passwords" ``` ### lpass share rm #### Description Removes a shared folder. #### Example ```bash # Remove shared folder lpass share rm "Team-Passwords" ``` ### lpass share userls #### Description Lists users with access to a shared folder. #### Example ```bash # List users in shared folder lpass share userls "Team-Passwords" ``` ### lpass share useradd #### Description Adds a user to a shared folder with specified permissions. #### Example ```bash # Add user with default permissions lpass share useradd "Team-Passwords" colleague@example.com # Add user with read-only access lpass share useradd --read-only=true "Team-Passwords" colleague@example.com # Add user with hidden passwords lpass share useradd --hidden=true "Team-Passwords" colleague@example.com # Add user as administrator lpass share useradd --admin=true "Team-Passwords" colleague@example.com # Add user with multiple options lpass share useradd --read-only=true --hidden=false "Team-Passwords" colleague@example.com ``` ### lpass share usermod #### Description Modifies user permissions in a shared folder. #### Example ```bash # Make user read-only lpass share usermod --read-only=true "Team-Passwords" colleague@example.com # Grant admin privileges lpass share usermod --admin=true "Team-Passwords" colleague@example.com # Remove hidden flag lpass share usermod --hidden=false "Team-Passwords" colleague@example.com ``` ``` -------------------------------- ### Generate Random Password Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Creates a randomly generated password for a specified key name. Optionally adds a URL and username, and inserts the generated password. ```bash lpass generate [url] [username] ``` -------------------------------- ### lpass Import and Export Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Commands for importing data into LastPass from a file and exporting data from LastPass. The import command supports options to keep duplicate entries, while the export command allows specifying which fields to include. ```bash lpass import [--sync=auto|now|no] [--keep-dupes] [FILENAME] lpass export [--sync=auto|now|no] [--color=auto|never|always] [--fields=FIELDLIST] ``` -------------------------------- ### List LastPass Entries Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Lists entry names in a tree structure. The '--long' ('-l') option includes the last modification time, and the '-u' option shows the last use time. Both times are in GMT. ```bash lpass ls [-l] [-u] [--format=FORMAT] ``` -------------------------------- ### Add LastPass Credentials Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to add new accounts or secure notes to your LastPass vault. Supports interactive creation via an editor or non-interactive creation using piped input for specific fields. ```bash lpass add work/email printf "Username: myuser\nPassword: mypassword123" | lpass add work/email --non-interactive printf "Username: myuser\nPassword: secret\nURL: https://example.com" | lpass add example-login --non-interactive lpass add --note-type=ssn info/my-ssn ``` -------------------------------- ### Import and Export Vault Data Source: https://context7.com/lastpass/lastpass-cli/llms.txt Utilities for backing up vault data to CSV or restoring data from files. Supports piping for GPG encryption and decryption workflows. ```bash lpass export --fields=name,url,username,password > backup.csv lpass export | gpg -e -r user@example.com > backup.csv.gpg gpg -d backup.csv.gpg | lpass import ``` -------------------------------- ### lpass edit Source: https://context7.com/lastpass/lastpass-cli/llms.txt Modifies existing accounts or secure notes in your vault. ```APIDOC ## lpass edit ### Description Modifies existing accounts or secure notes in your vault. ### Examples ```bash # Edit all fields interactively (opens editor) lpass edit mysite.com # Edit only the password lpass edit --password mysite.com # Edit username lpass edit --username mysite.com # Edit URL lpass edit --url mysite.com # Edit notes lpass edit --notes mysite.com # Edit custom field lpass edit --field=pin mysite.com # Rename an account lpass edit --name mysite.com # Non-interactive edit (reads from stdin) echo "newpassword123" | lpass edit --password --non-interactive mysite.com # Edit by unique ID lpass edit --password 140613939481239829 # Edit with immediate sync lpass edit --sync=now --password mysite.com ``` ``` -------------------------------- ### lpass Share Management Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt These commands manage shared folders within LastPass. They allow listing users of a share, adding, modifying, or deleting users, creating new shares, removing shares, and managing user permissions for specific sites within a share. ```bash lpass share userls SHARE lpass share useradd [--read-only=[true|false]] [--hidden=[true|false]] [--admin=[true|false]] SHARE USERNAME lpass share usermod [--read-only=[true|false]] [--hidden=[true|false]] [--admin=[true|false]] SHARE USERNAME lpass share userdel SHARE USERNAME lpass share create SHARE lpass share rm SHARE lpass share limit [--deny|--allow] [--add|--rm|--clear] SHARE USERNAME [sites] ``` -------------------------------- ### Export LastPass Data Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Dumps all account information, including passwords, to stdout in unencrypted CSV format. Supports exporting a subset of fields using the '--fields' argument. ```bash lpass export [--fields=FIELDLIST] ``` -------------------------------- ### Manage Shared Folder Access Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands to remove users from shared folders and manage site-specific access restrictions including whitelisting and blacklisting. ```bash # Remove user from shared folder lpass share userdel "Team-Passwords" colleague@example.com # Show current access limits for a user lpass share limit "Team-Passwords" colleague@example.com # Add site to whitelist lpass share limit --allow --add "Team-Passwords" colleague@example.com site1 site2 # Add site to blacklist lpass share limit --deny --add "Team-Passwords" colleague@example.com restricted-site # Remove site from access list lpass share limit --rm "Team-Passwords" colleague@example.com site1 # Clear all access restrictions lpass share limit --clear "Team-Passwords" colleague@example.com ``` -------------------------------- ### Check LastPass CLI Status Source: https://context7.com/lastpass/lastpass-cli/llms.txt Command to check the current login status and whether the lpass agent is running. Supports a quiet mode for scripting that returns an exit code. ```bash lpass status lpass status --quiet ``` -------------------------------- ### Logout from LastPass CLI Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Removes the local cache and stored encryption keys. The command will prompt for confirmation unless the '--force' option is specified. ```bash lpass logout [--force] ``` -------------------------------- ### Manage Vault Items with lpass Source: https://context7.com/lastpass/lastpass-cli/llms.txt Commands for creating, modifying, duplicating, and deleting vault entries. These operations support both interactive and non-interactive modes, as well as identification by name or unique ID. ```bash lpass add --notes "my notes" my-note-name --non-interactive lpass edit --password mysite.com echo "newpassword123" | lpass edit --password --non-interactive mysite.com lpass generate --username=admin --url=https://admin.example.com work/server 32 lpass mv mysite.com "Personal\\Banking" lpass duplicate mysite.com lpass rm --sync=now mysite.com ``` -------------------------------- ### Duplicate LastPass Entry Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Creates a duplicate of a specified LastPass entry with a different ID. ```bash lpass duplicate ``` -------------------------------- ### lpass rm Source: https://context7.com/lastpass/lastpass-cli/llms.txt Removes an account from the vault. ```APIDOC ## lpass rm ### Description Removes an account from the vault. ### Examples ```bash # Remove an account lpass rm mysite.com # Remove by unique ID lpass rm 140613939481239829 # Remove with immediate sync lpass rm --sync=now mysite.com ``` ``` -------------------------------- ### Remove LastPass Entry Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Removes the specified LastPass entry. ```bash lpass rm ``` -------------------------------- ### lpass export Source: https://context7.com/lastpass/lastpass-cli/llms.txt Exports all vault data to CSV format (unencrypted). ```APIDOC ## lpass export ### Description Exports all vault data to CSV format (unencrypted). ### Examples ```bash # Export all accounts to stdout lpass export # Export to file lpass export > backup.csv # Export with specific fields lpass export --fields=name,url,username,password # Export and encrypt with GPG lpass export | gpg -e -r user@example.com > backup.csv.gpg # Available fields: # id, url, username, password, extra, name, fav, grouping, # group, fullname, last_touch, last_modified_gmt, attachpresent ``` ``` -------------------------------- ### Edit LastPass Entry Field Source: https://github.com/lastpass/lastpass-cli/blob/master/lpass.1.txt Edits a selected field of a LastPass entry. If '--non-interactive' is not set, it uses the default editor. Otherwise, it accepts data until EOF or the first newline (unless editing notes). ```bash lpass edit [--non-interactive] ``` -------------------------------- ### Change LastPass Master Password Source: https://context7.com/lastpass/lastpass-cli/llms.txt Command to change your LastPass master password. This operation re-encrypts all records in your vault with a new key derived from the new password. ```bash lpass passwd ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.