lastpass / lastpass-cli

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

let a login survive after docker container restart... #512

Open masavini opened 5 years ago

masavini commented 5 years ago

hi, i create a simple docker image for lastpass-cli with this Dockerfile:

FROM alpine:latest

RUN apk --update --upgrade add \
    lastpass-cli

then i create a container, mounting a volume for persistence:

docker run \
    --detach \
    --interactive \
    --volume ~/.lpass:/root/.lpass \
    --name lpass \
    lpass

i login, setting the agent to never quit:

docker exec \
      --interactive \
      --tty \
      --env LPASS_AGENT_TIMEOUT=0 \
      lpass \
      lpass login "${LPASS_USR}"

so far, so good: the agent never quits, and i can run lpass commands for the whole day without having to login again:

docker exec lpass lpass status
Logged in as bubu@gmail.com.

if i stop and start the container again, however, it gets logged out... i guess it's because when the container is stopped, the agent quits as well, no matter the LPASS_AGENT_TIMEOUT=0 nor the persistent volume...

i've also tried committing a new image from the logged in container, but any container started from the new image is not logged in...

is any way to let the login survive a container restart?

dustinblainemyers commented 5 years ago

I thought docker containers didn't have persistent state ?

dustinblainemyers commented 5 years ago

I know you have your last pass in a persistent volume . I am new to docker so I am trying to understand how that is supposed to work to keep your session state persistent ? When you restart your docker container are you passing in your log in info again ? Even though the last pass volume is persistent still seems like you would have to pass the login to docker ...because to last pass that would be logging into a completely new machine. Just trying to see my failure in understanding.

masavini commented 5 years ago

i solved simply logging in with the --plaintext-key option and mounting a host directory for the config dir persistency. less secure, but perfectly working...