-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect-Keeper: Automatically perform actions on DeviceAuth and TwoFactor #125
Comments
If a Keeper client is used in a hosted environment (there is no user interaction) we suggest to prepare a configuration file |
Thank you! That seems a bit easier. But I can't seem to get it to work. I generate the config file like this: $otp = Get-Otp $KeeperTotpSecret
$KeeperConfig = @'
{{
"server":"https://keepersecurity.com/api/v2/",
"user":"{0}",
"password":"{1}",
"mfa_type":"device_token",
"mfa_token":"{2}",
"debug":false,
"commands":[]
}}
'@
[string]::format($KeeperConfig, $KeeperUser, (ConvertFrom-SecureString -SecureString $KeeperPassword -AsPlainText), $otp) | Out-File -FilePath config.json Run Connect-Keeper once, enter the 2FA token and then try to connect again: Connect-Keeper -Username $KeeperUser
... entering 2FA and masterpassword
Connect-Keeper
... prompted for 2FA and masterpassword again If I specify the password and username on the CLI, I only get prompted for the 2FA: Connect-Keeper -Username $KeeperUser -Password $KeeperPassword -SsoPassword
... prompted for the 2FA |
I can see that you use a different format for the config file. That is the Python's Commander config file.
|
If device approval step appears every login it means the library creates a new (so called) "device" and the backend enforces a full login flow. |
I see. I got it to work now after I deleted the entire config file and let powercommander make it from scratch. I've been able to use the config file on a headless system, so it works for my purposes. Thank you very much for your help! |
@bror-lauritz Hey sorry to ping you here but do you happen to have an example of how you got unnatended auth to work with the powershell module? I think I've correctly constructed the config.json but Connect-Keeper just keeps asking for device approval and is not giving any feedback on if its detecting the json or not. |
@rvdwegen If The default file location is the path returned by
Windows: %USER_HOME%\Documents.keeper Posix: $USER_HOME/.keeper The config file can be setup for persistent login using |
Hi, your support replied with similar instructions which I'll try out tomorrow. But does that mean the powershell module itself can't be used to generate the config.json? |
Powershell module generates |
Hi @rvdwegen! In my experience this works quite well (I'm on Linux, so YMMV): New-Item -Type File -Name config.json
$USERNAME = Read-Host -Prompt "Keeper username"
$PASSWORD = Read-Host -AsSecureString -Prompt "Keeper password"
Connect-Keeper -Username $USERNAME -Password $PASSWORD -SsoPassword (Some of the flags might not be necessary in your case) You probably want to set It's based on that Keeper finds the NOTE: I think you still need to supply the password whenever you run Connect-Keeper, but you don't have to use the 2FA code or authenticate the device. |
Unfortunately that still seems to result in a demand to input the password? I'm looking to use the PowerShell module (not .dotnet KeeperCommander) fully unnatended in either a function app or azure automation account. The dotnet PowerCommander is correctly logging in completely unnatended now as soon as I start Keeper so the JSON is working now.
The config file dotnet PowerCommander generated looks nothing like the above example though. |
If your setup is like our organization, you have to specify the |
I did, I've tried every combination that made sense. |
Hey i'd like to follow up on the masterpassword prompt. either i go through: it always ask me to enter the master password, but i want to get it done automatically { |
PowerCommander ignored "password" property of the configuration file. Passing user's password in the command line should work.
|
Yep, works here too now. |
When running Connect-Keeper, I want to be able to automatically answer the DeviceAuth and TwoFactor steps in the AuthFlow. I've tried to answer them by piping the answer into another process, which partially works but is quite fragile.
What I want to do
Consider the TwoFactor step:
I want to automatically answer the OTP here.
The same for DeviceAuth, but I want to first send "channel=2fa" and then the OTP.
What I have implemented
My current solution patches Connect-Keeper as defined in
AuthCommands.ps1
with two new parameters and two if statements (see commented areas)I can then run this to do all the steps I'd like:
(I don't know if the actions should be secure string or not, from a security perspective)
Limitations with my method
This works pretty well for my purposes, but I'd like for something like this in the source so I don't have to verify that it works after every new release.
One drawback is that it still unnecessarily prints out
The text was updated successfully, but these errors were encountered: