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

标签 powershell ubuntu

我想在自动化中使用 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命令,获取配置不再起作用。
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 永久禁用您的 secret 存储的密码验证。 .系统将要求您提供两次当前密码,作为确认,然后您就应该准备好了。
前:

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

关于powershell - 禁用 SecretStore 密码提示以实现自动化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67554465/

相关文章:

php - Powershell调用后批处理脚本将不会返回

regex - 分割 CSV 文件中的字符串

powershell - 具有十六进制值的 Invoke-WebRequest

android - Ubuntu android studio安装错误

linux - 如何运行脚本取决于不同的停止时间

powershell - 复制文件名中带有方括号 [] 的文件并使用 * 通配符

服务器重启后 mysqld.sock 丢失; MySQL 服务器启动失败

linux - 虚拟示波器的模拟输入

php - 从 PHP 连接到 127.0.0.1 处的 MySQL 时出错

azure - 在 PowerShell 中将字符串表达式转换为日期类型