12

I'm trying to connect to a remote Windows 7 box that needs a setup change or two. I've got access to an Administrator account via Cygwin's SSH server, but Cygwin won't let me run Administrator-privilege utilities ("The requested operation requires elevation (Run as administrator.)")

The standard solution for this is, to the best of my knowledge, RunAs.exe, but trying to run it via SSH results in it quitting instantly with no diagnostic (even when run as "runas /?"). Starting "cmd" from ssh gives me a standard DOS prompt, but from the DOS prompt, "runas" just echoes the commandline back at me no matter what I do, again, even when run as "runas /?".

Cygwin won't let me connect as Administrator@computername.

Any suggestions?

1
  • 3
    bump I'd like to know the answer to this too.
    – user73139
    Mar 23, 2011 at 22:37

5 Answers 5

4

If you log in to sshd with password authentication, then you authenticate simultaneously to Windows and should be granted your account's administrative rights. If you log in with public key authentication, then sshd makes an end run around Windows authentication, and you'll only ever have standard user rights.

For more information, see Corinna's answer to this question from 2004. See also the recent thread on the Cygwin mailing list about admin rights over ssh.

2
  • It's maddening that you get administrative rights with public key authentication with workgroup workstations (Windows 10) but not for Domain-connected servers (Windows Server 2012).
    – C Fraire
    Feb 25, 2017 at 5:54
  • Don't know how many hours I spent on consequences of the above observation but I'm glad to have found the distinction. If you get weird errors trying to ls the contents of mapped network drives, this might have something to do with why. Oct 27, 2023 at 21:43
0

Have you tried to do runas against cmd.exe?

Logically that would open cmd.exe with an elevated permissions set allowing you to do whatever you like as the administrator. I'm not a Windows user so I can't really test it.

0

Right click on your Cygwin shortcut or executable and select the "Run as Administrator" option. This should open a Cygwin terminal and give you elevated permissions in that terminal.

2
  • 1
    Doesn't work when coming in from the outside - that's why the whole "SSH" thing is important.
    – ZorbaTHut
    Nov 8, 2012 at 1:07
  • This answer worked for me, upvoted.
    – CHarris
    Aug 1, 2016 at 0:00
0

Summary

Runas might not be supported but you could use a freeware utility CPAU http://www.joeware.net/freetools/tools/cpau/index.htm

This utility will allow you to launch an application using a different set of credentials then the current user. The neat advantage with CPAU over runas is that you can specify both the username and password at runtime. With the runas command you'd first have to configure a cached credential or be prompted for password at each run.

Examples

Using CPAU to launch iexplore.exe you could use a statement like:

from cmd prompt:

cd <path to cpau> -d
cpau.exe  /u domain\username  /p 123456  /ex "c:\Program Files (x86)\Internet Explorer\iexplore.exe" /lwp

from powershell script:

cd <path to cpau> -d
invoke-expression "cpau.exe  /u 'domain\username'  /p '123456'  /ex 'c:\Program Files (x86)\Internet Explorer\iexplore.exe' /lwp"

/lwp means to Load With Profile, and can be replaced with /lwop Load Without Profile

2
  • Have you tried whether this works in Cygwin?
    – Daniel Beck
    May 2, 2013 at 15:34
  • I would presume it would as you could launch a cmd window with this solution then have access to cygwin commmands.
    – Ro Yo Mi
    May 2, 2013 at 17:24
0

I landed on this question after searching for a solution for the exact same symptoms (e.g. runas does not provide any output whatsoever, not even runas /?), but from a plain cygwin terminal window. I also found this answer which suggests running

$ cygstart --action=runas command

and for me that did provide a successfull outcome.

1
  • the important point of the OP's question is the remote part: cygstart --action=runas only hangs and does show any credential window via the ssh connection (how could it?)
    – Seki
    Mar 17, 2016 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .