Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "sudo" utility to quickly execute a single command as Admin inside a cmd/powershell console #63

Closed
lorenzobilli opened this issue May 9, 2019 · 12 comments
Labels
Idea-New PowerToy Suggestion for a PowerToy

Comments

@lorenzobilli
Copy link

I think it would be very useful to have a command/utility that behaves likes the classic "sudo" on *NIX systems inside consoles.

As you know the only quick and dirty way to execute a cmd or powershell command as Administrator is to open an elevated console first and then execute the required command.

This is a much more cumbersome way to obtain Administrator privileges, and it's quite annoying when you often try to execute a single command that needs Admin privileges inside a standard console, since it forces you to open another console as Administrator, then retype the entire command and execute it. A sudo-like utility would be a dream.

@PowerWindowsXP
Copy link

This is a awesome idea. But since Ubuntu she'll is going to be in the new windows terminal I see only a temporary need.

@malxau
Copy link

malxau commented May 10, 2019

@PowerWindowsXP - I don't think that's the same thing. sudo within Ubuntu means root within the WSL VM. sudo within CMD/PS means run in elevated context in the Windows host.

@glen-84
Copy link

glen-84 commented May 10, 2019

See also microsoft/terminal#146.

@bendyson
Copy link

I may be mistaken, but can't this be done using the runas command?

@orev
Copy link

orev commented May 12, 2019

This cannot be done with "runas" command. The most important feature of 'sudo' is that it asks for your password, not the admin password. This little detail makes a dramatic difference.

There are often times when you need to allow a user to execute a single command as Admin, but don't want to / cannot give them an admin account, because then that would allow them to run anything as admin. Sudo style allows you to whitelist commands they can run, and also prevents the need to share the full admin password.

I know there are other security issues with this, such as once the program is started as Admin, one could possibly launch other commands or access files as Admin, but that is specific to each application and should be a decision made by an Administrator. I'm also sure someone will argue that you can "usually" use a shim or something to get around the Admin requirement, but there are situations where you can't. Again, it should be up to the Administrator.

@jaimecbernardo jaimecbernardo added the Idea-New PowerToy Suggestion for a PowerToy label May 13, 2019
@felintusun
Copy link

sudo in a native way would be nice :).
There is a sudo implementation by lukesampson that works quite good for me.
http://blog.lukesampson.com/sudo-for-windows

@lorenzobilli
Copy link
Author

@felintusun yeah I'm actually using it too. However it doesn't seem to work 100% with PowerShell Core. Yeah, a native, "official" sudo would be nicer :)

@klaernie
Copy link

klaernie commented Sep 6, 2019

One should also add: if you try scripting for multiple different machines where certain commands need to be executed as another user you always run into the problem, that even with you being elevated you need the target users password to run anything or schedule a task for them. And this isn't even a security benefit, as you could as admin always set a login script in the registry that breaks the target users session, so it isn't like requiring the password would remedy the last security hole. It only makes a mess for people scripting. I probably have discarded 20 automation attempts, simply because I can't make this user switch work without transporting the target user's password as well.

ryanbodrug-microsoft pushed a commit to ryanbodrug-microsoft/PowerToys that referenced this issue Apr 14, 2020
…erselection

Add return to main query window from context menu after selection
@ghost ghost mentioned this issue Oct 19, 2020
@ghost
Copy link

ghost commented Oct 21, 2020

There is a better tool for this -> gerardog/gsudo

It is written in C#, licensed under MIT, works well with PowerShell Core

@crutkas It would be cool if we could integrate this project

@just1a-person
Copy link
Contributor

There is a better tool for this -> gerardog/gsudo

It is written in C#, licensed under MIT, works well with PowerShell Core

@crutkas It would be cool if we could integrate this project

Even though I suggested this, I now know this is going to be a bad idea for PowerToys to implement this. The security "infrastructure" in Windows is totally different from Linux making it impossible to make a "safe sudo" for Windows.

/cc @crutkas

@UEFI-code
Copy link

There is tool called "NSUDO", which let you create a process with TrustInstaller premission, and you can del & kill system process easily

@joadoumie
Copy link
Contributor

joadoumie commented Feb 12, 2024

We've just announced Sudo for Windows. We're working hard to field feedback for missing features, so please go thumbs up an issue if you see something you'd like added or create a new feature request on the sudo GitHub repo!

Closing out this issue as we'll do all the feature request tracking etc. in the new repository :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idea-New PowerToy Suggestion for a PowerToy
Projects
None yet
Development

No branches or pull requests