Using a password manager is great (though a troubling central point of failure). We can use command line tools to get the password from them rather than storing them in files which is much cleaner.

lpass and login

On OSX:

1
brew install lastpass-cli

or Debian:

1
sudo apt-get install lastpass-cli

Checking to see if you are logged in

1
2
3
4
if ! lpass status; then
  echo Please log in
  lpass login wschenk@gmail.com
fi

Using it in a script

1
2
  POCKET_USER=`lpass show –password pocketcasts.com |awk '/Username/ { print $2}'`
  POCKET_PASS=`lpass show –password pocketcasts.com |awk '/Password/ { print $2}'`

Or if you want to pull stuff using ruby:

1
2
3
4
5
6
7
8
9
  require 'open3'

  # Run the "lpass show" command to retrieve the Instapaper API key and username
  output, status = Open3.capture2('lpass', 'show', 'Instapaper API Key')
  if status.success?
    # Extract the API key and username from the output
    api_key = output.match(/Consumer ID: (.+)/)[1]
    api_secret = output.match(/Consumer Secret: (.+)/)[1] 
  end

References

  1. https://github.com/lastpass/lastpass-cli
  2. https://support.lastpass.com/help/use-the-lastpass-command-line-application-lp040011

Previously

The Most Amazing — and Dangerous — Technology in the World

2023-04-04

Next

Dan Gillmor on why (and how) journalists should leave Twitter for Mastodon

2023-04-06

labnotes

Previously

Snowpack for fast builds react and tailwind too

2022-01-02

Next

Using Mrsk Deployment testing

2023-06-05