Skip to content

Correct way to do privilege elevation like sudo? #1308

Closed
@RaymiiOrg

Description

@RaymiiOrg

I'm looking for a way to do sudo-like privilege elevation. Administrators are not allowed to login, so as a regular user I need a way to become Administrator to do privileged actions, in the same ssh session. I've written down a way with Powershell here:

https://raymii.org/s/tutorials/SSH_on_Windows_Server_2019.html#sudo

$Username = 'Administrator'
$Password = 'P@ssw0rd'
$Pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$Pass

Enter-PSSession -ComputerName localhost -Credential $Cred

Example output:

[localhost]: PS C:\Users\Administrator\Documents> whoami
win-doipgfhik47\administrator

But that is not as easy as just "sudo". What is the correct way to do privilege elevation?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions