禁用 SecretStore 密码提示以实现自动化

问题描述

我想在自动化中使用 secretstore,但是,我无法摆脱密码提示。我采取的步骤如下:

1- 重置 secretstore -> 要求输入密码(强制)。

2- 将交互设置为无 -> 返回错误

3- 解锁 -> 要求输入密码

输出可以在下面列出:

PS /home/mahmood> Reset-secretstore -Passthru
WARNING: !!This operation completely removes all secretstore module secrets and resets configuration settings to new values!!

Reset secretstore
Are you sure you want to erase all secrets in secretstore and reset configuration settings to default?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
Creating a new Microsoft.PowerShell.secretstore vault. A password is required by the current store configuration.
Enter password:
************
Enter password again for verification:
************

      Scope Authentication PasswordTimeout Interaction
      ----- -------------- --------------- -----------
CurrentUser       Password             900      Prompt

PS /home/mahmood> Set-secretstoreConfiguration -Interaction None

Confirm
Are you sure you want to perform this action?
Performing the operation "Changes local store configuration" on target "secretstore module local store".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
PS /home/mahmood> Get-secretstoreConfiguration
Get-secretstoreConfiguration: A valid password is required to access the Microsoft.PowerShell.secretstore vault.
Use the Unlock-secretstore cmdlet to provide the required password to access the store.
PS /home/mahmood> Unlock-secretstore

cmdlet Unlock-secretstore at command pipeline position 1
Supply values for the following parameters:
Password: ************
PS /home/mahmood> Get-secretstoreConfiguration

      Scope Authentication PasswordTimeout Interaction
      ----- -------------- --------------- -----------
CurrentUser       Password             900        None

如您所见,虽然交互现在是“无”,但是,当我重新运行 pwsh 命令时,get 配置不再起作用。

PS /home/mahmood> exit
mahmood@Frontend:~$ pwsh
PowerShell 7.1.3
copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/mahmood> Get-secretstoreConfiguration
Get-secretstoreConfiguration: A valid password is required to access the Microsoft.PowerShell.secretstore vault.
Use the Unlock-secretstore cmdlet to provide the required password to access the store.

我该如何解决

解决方法

您可以使用 Set-SecretStoreConfiguration -Authentication None 永久禁用您的机密存储的密码身份验证。系统会要求您提供两次当前密码,作为确认,然后您就应该设置好了。

之前:

PS> Get-SecretStoreConfiguration

      Scope Authentication PasswordTimeout Interaction
      ----- -------------- --------------- -----------
CurrentUser       Password             900      Prompt

禁用

PS> Set-SecretStoreConfiguration -Authentication None
Confirm
Are you sure you want to perform this action?
Performing the operation "Changes local store configuration" on target "SecretStore module local store".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
Vault Microsoft.PowerShell.SecretStore requires a password.
Enter password:
******
A password is no longer required for the local store configuration.
To complete the change please provide the current password.
Enter password:
******

之后:

PS> Get-SecretStoreConfiguration

      Scope Authentication PasswordTimeout Interaction
      ----- -------------- --------------- -----------
CurrentUser           None             900      Prompt

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...