Configurando o AWS Tools for PowerShell Core no Linux

0

O utilitário da AWS tem esse dizer sobre privilégios:

Note

Although you can start PowerShell by running sudo pwsh to run PowerShell with elevated rights, be aware that this is a potential security risk, and not consistent with the principle of least privilege.

É justo, mas como o módulo é instalado?

thufir@dur:~$ 
thufir@dur:~$ pwsh
PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/thufir> 
PS /home/thufir> Install-Module -Name AWSPowerShell.NetCore                                                             
Install-Module : Administrator rights are required to install modules in '/usr/local/share/powershell/Modules'. Log on to the computer with an account that has Administrator rights, and then try again, or install '/home/thufir/.local/share/powershell/Modules' by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).
At line:1 char:1
+ Install-Module -Name AWSPowerShell.NetCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Install-Module], ArgumentException
+ FullyQualifiedErrorId : InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser,Install-Module

PS /home/thufir> 
PS /home/thufir> exit                                                                                                   
thufir@dur:~$ 
thufir@dur:~$ 
thufir@dur:~$ sudo pwsh
[sudo] password for thufir: 
PowerShell v6.0.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /home/thufir> 
PS /home/thufir> Install-Module -Name AWSPowerShell.NetCore                                                             

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its 
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 
'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): n
WARNING: User declined to install module (AWSPowerShell.NetCore).
PS /home/thufir> 
PS /home/thufir> exit                                                                                                   
thufir@dur:~$ 
    
por Thufir 04.04.2018 / 10:33

1 resposta

1

Eu acredito que eles acidentalmente trocaram os comandos aqui:

Next, run Install-Module as shown in the following command.

PS> Install-Module -Name AWSPowerShell.NetCore -AllowClobber

It is not necessary to run this command as Administrator, unless you want to install the AWS Tools for PowerShell Core for all users of a computer. To do this, run the following command in a PowerShell session that you have started with sudo pwsh:

PS> Install-Module -Scope CurrentUser -Name AWSPowerShell.NetCore -Force

-Scope CurrentUser instala isso apenas para seu usuário e não precisa de privilégios de administrador. Sem isso, instala o módulo para todos os usuários e precisa de privilégios. Consulte a a documentação Install-Modules :

When no scope is defined, or when the value of the Scope parameter is AllUsers, the module is installed to %systemdrive%:\Program Files\WindowsPowerShell\Modules. When the value of Scope is CurrentUser, the module is installed to $home\Documents\WindowsPowerShell\Modules.

Para instalar sem sudo , use -Scope CurrentUser . Isso é como --user para pip install , por exemplo.

    
por muru 04.04.2018 / 11:21