CLI ,two master passwords

% bw get template folder | jq '.name="mycat"' | bw encode | bw create folder 
 
? Master password: [hidden]
? Master password: [hidden]
Invalid master password.
 
`

I cannot delete one of the passwords screen . Are any solution for this ? . I newer seen this before . Today I moved the bw cli to /opt/local/bin/bw ,can this cause something like this ? Or I may misunderstand something ?

Did you try using bw login to log in first, before trying to create the folder?

I could create a folder ,but in 3 steps ,so really I do not know why it most take 3 steps .

 bw get template folder | jq '.name="lätta"'
{
  "name": "lätta"
}
    %  bw get template folder | jq '.name="lätta"' | bw encode 
ewogICJuYW1lIjogImzDpHR0YSIKfQo=

  % bw create folder ewogICJuYW1lIjogImzDpHR0YSIKfQo=
{"object":"folder","id":"c58d3712-999e-430f-ad24-b3580101262b","name":"lätta"}

The folder is only a testing folder it does not exist , now I am not asked at every step as I set bw to Bitwarden environment ,or what it is called , but it takes 3 step in any way .

I think I got that 2 passwords screen because I tried to jump over the bw encode command - but not as I typed the full command out after that json output.

bw get template folder | jq '.name="lätta"' | bw encode | bw create folder

Did not worked and those 2 passwords screen appeared .

So I do not know if there are a one way to create a folder - it is wery simple - but in 3 steps.

Did you set the BW_SESSION environment variable to the session key?

Yes I did ,but still I do not really understand why I need to go 3 steps before a folder is created.

bw get template folder | jq '.name="My First Folder"'
{
  "name": "My First Folder"
}

After this ,it should go in to that long command an a folder is created ?

bw get template folder | jq '.name="My First Folder"' | bw encode | bw create folder

After this the folder should be created ? So I jumped over the second step ,and that is bw encode , but in the command above it is there bw encode ,this 2 step which created all those 2 passwords screen , as I believe ,. I do not know how this really works .

How long the BW_SESSION is active ? I mean in time ,say 1 hour or 2 hours ?.I newer used it as I am not often use the CLI - I set it up because of those passwords typing was really annoying.

But the 2 passwords screen appearing - I think that is because “ bw encode” command I tried to jump over .

BW_SESSION is valid as long as you do not lock or logout (by running bw lock or bw logout, for example). If the server, for whatever reason logs you out, then it also will become invalid.

But there is no timeout for the CLI session to be active (like there is in other clients).

Running this:

bw get template folder | jq ‘.name=“My First Folder”’ | bw encode | bw create folder

Is like running these commands sequentially:

  1. bw get template folder
  2. jq ‘.name=“My First Folder”’
  3. bw encode
  4. bw create folder

Commands number 1 and 4 require the CLI to be logged in and unlocked, command number 3 does not.

If a CLI command requires the CLI to be logged in and unlocked and you do not pass a valid BW_SESSION to it, then it will ask for your master password, every time.

That’s why you are prompted two times to enter your master password.

Btw, this is all explained in the help page I posted for you earlier. You should read it.

1 Like

Thanks so wery much ,this explained a lot. I read the help section too .After logged in and unlocked my vault the commands works in one stretch !!!

bw get template folder | jq '.name="mycat bernie"' | bw encode | bw create folder 

It would be wery undesirable to copy and paste that long code and then use bw create ….

Did @kpiris post solve your issue? Just asking because then it could be marked as the solution.

Yes it solved the problem ,it works wery well now . It was wery strange phenomenon after all ,but setting bw to session variable ,it solved the problem

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.