Configure the behavior of the sudo command
Configurer le comportement de la commande sudo
Explanation
This policy setting controls use of the sudo.exe command line tool.
If you enable this policy setting, then you may set a maximum allowed mode to run sudo in. This restricts the ways in which users may interact with command-line applications run with sudo. You may pick one of the following modes to allow sudo to run in:
"Disabled": sudo is entirely disabled on this machine. When the user tries to run sudo, sudo will print an error message and exit.
"Force new window": When sudo launches a command line application, it will launch that app in a new console window.
"Disable input": When sudo launches a command line application, it will launch the app in the current console window, but the user will not be able to type input to the command line app. The user may also choose to run sudo in "Force new window" mode.
"Normal": When sudo launches a command line application, it will launch the app in the current console window. The user may also choose to run sudo in "Force new window" or "Disable input" mode.
If you disable this policy or do not configure it, the user will be able to run sudo.exe normally (after enabling the setting in the Settings app).
Ce paramètre de stratégie contrôle l’utilisation de l’outil de ligne de commande sudo.exe.
Si vous activez ce paramètre de stratégie, vous pouvez définir un mode maximum autorisé pour l’exécution de sudo. Cette option limite la manière dont les utilisateurs peuvent interagir avec les applications en ligne de commande exécutées avec sudo. Pour permettre à sudo de fonctionner, vous pouvez choisir l’un des modes suivants :
« Désactivé » : sudo est entièrement désactivé sur cet ordinateur. Lorsque l’utilisateur essaie d’exécuter sudo, celui-ci affiche un message d’erreur et se ferme.
« Forcer une nouvelle fenêtre » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans une nouvelle fenêtre de console.
« Désactiver l’entrée » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans la fenêtre de console courante, mais l’utilisateur ne peut pas saisir de données dans l’application en ligne de commande. L’utilisateur peut également choisir d’exécuter sudo en mode « Forcer une nouvelle fenêtre ».
« Normal » : Lorsque sudo lance une application en ligne de commande, celle-ci est lancée dans la fenêtre de console courante. L’utilisateur peut également choisir d’exécuter sudo en mode « Forcer une nouvelle fenêtre » ou « Désactiver la saisie ».
Si vous désactivez cette stratégie ou ne la configurez pas, l’utilisateur pourra exécuter sudo.exe normalement (après avoir activé le paramètre dans l’application Paramètres).
Registry
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Sudo- Value name
- not defined in the ADMX
Enable / disable values: not defined in the ADMX (see the options below).
PowerShell
PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.
Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.
Enable
# Enable: Sudo/EnableSudo
$k = 'HKLM:\Software\Policies\Microsoft\Windows\Sudo'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
# Maximum allowed sudo mode
# Possible options:
# Disabled = 0
# Force new window = 1
# Disable input = 2
# Normal = 3
Set-ItemProperty -Path $k -Name 'Enabled' -Value 0 -Type DWordDisable
# Disable: Sudo/EnableSudo
# No value is written in the "Disabled" state (nothing defined in the ADMX)Revert to "Not configured"
# Revert to "Not configured": Sudo/EnableSudo
$k = 'HKLM:\Software\Policies\Microsoft\Windows\Sudo'
Remove-ItemProperty -Path $k -Name 'Enabled' -ErrorAction SilentlyContinueOptions (1)
| Label | Control | Registry value | REG type | Constraints / details | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Maximum allowed sudo modeMode sudo maximum autoriséSudoModes | Drop-down listenum | Enabled | REG_DWORD | Default choice (UI): #0
|