Win32-OpenSSH icon indicating copy to clipboard operation
Win32-OpenSSH copied to clipboard

Configure OpenSSH using Service Account.

Open akshay8043 opened this issue 4 years ago • 9 comments
trafficstars

Troubleshooting steps https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps

Terminal issue? please go through wiki https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

Please answer the following

"OpenSSH for Windows" version ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion) Latest

Server OperatingSystem ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName) Win10 Pro

What is failing Unable to run openssh service using Domain Service account. Also, I want to use Chroot for that same service account.

Actual output

akshay8043 avatar Jun 30 '21 21:06 akshay8043

error 1297 when starting service using service account

akshay8043 avatar Jul 01 '21 19:07 akshay8043

Your description is extremely brief. Could you please provide a sequence of instructions (e.g. command lines) that will allow us to exactly reproduce this error?

mgkuhn avatar Aug 13 '21 16:08 mgkuhn

Can I resurrect this issue? I'm also interested in running OpenSSH on Windows under a service account (instead of SYSTEM). The steps to reproduce the issue are: (0.) Install OpenSSH 8.9.1 on Windows Server 2016.

  1. Create a local account on the Windows machine where OpenSSH server is installed.
  2. Grant the account "Log on as a service" rights on the machine.
  3. Go to the properties of the OpenSSH SSH Server service (in services.msc), go to the "Log On" tab, and specify "This Account" to log on as when starting the service. Enter the username and password created in step 1.
  4. Stop and restart the service.
  5. The service fails to start, and gives this error:

Windows could not start the OpenSSH SSH Server service on Local Computer. Error 1297: A Privilege that the service requires to function properly does not exist in the service account configuration.

image

scratchbuild1 avatar Nov 14 '22 16:11 scratchbuild1

Perhaps have e.g. a look at the !am_system() branches in get_user_token() in win32compat/win32_usertoken_utils.c to get an idea what privileges are required?

mgkuhn avatar Nov 14 '22 17:11 mgkuhn

I'm not really a developer, so I might be wrong, but it looks like it needs to be able to create a process-level token. There is a "User Right" in Windows for that, but it's considered to be a pretty big one, i.e. I'm not sure how big of a security win it would be to have it not be running as SYSTEM but give it the process token rights. That's the part where I don't know enough about coding to know how important that right is to the overall picture, or how hard it would be to re-work it so it doesn't need that. I'll explore doing it with user rights and report back in a few days...

scratchbuild1 avatar Nov 16 '22 15:11 scratchbuild1

Update: Adding the token-related user rights doesn't seem to allow it to run as a service account. Same error message as above is still produced. So, since it seems like it's doing some intentional checking before proceeding, this may be more in the realm of a "feature request," i.e. to add the ability to run as a non-admin service account.

scratchbuild1 avatar Nov 17 '22 17:11 scratchbuild1

I had the same issues and ended up comparing a few servers to get this working. I added my service account (DOMAIN\user-name) as an administrator and then made sure administrator existed on some policies (I don't know which are not required as admin already existed in many):

(run secpol.msc > local policies > user rights management)

image

Administrator exists in the following policies. The bold item was the last I updated before it started working.

  • Access Credential Manager as a trusted caller
  • Access this computer from the network
  • Act as part of the operating system
  • Adjust memory quotas for a process
  • Allow log on locally
  • Allow log on through remote desktop
  • Back up files and directories
  • Bypass traverse checking
  • Change the system time
  • Change the time zone
  • Create a pagefile
  • Create a token object
  • Create global objects
  • Create symbolic links
  • Debug programs
  • Enable computer and user accounts to be trusted for ...
  • Force shutdown from a remote system
  • Generate security audits
  • Impersonate a client after authentication
  • Increase scheduling priority
  • Load and unload device drivers
  • Lock pages in memory
  • Log on as a batch job
  • Log on as a service
  • Manage auditing and security log
  • Modify firmware environment values
  • Perform volume maintenance tasks
  • Profile single processes
  • Profile system performance
  • Remove computer from docking station
  • Replace a process level token
  • Restore files and directories
  • Shut down the system
  • Synchronize directory service data
  • Take ownership of files or other objects

christopherpickering avatar Jul 19 '23 18:07 christopherpickering

I had the same issues and ended up comparing a few servers to get this working. I added my service account (DOMAIN\user-name) as an administrator and then made sure administrator existed on some policies (I don't know which are not required as admin already existed in many):

(run secpol.msc > local policies > user rights management)

image

I only had to add my user account (which has admin rights) to these 2 policies:

  • Act as part of the operating system
  • Replace a process level token

t1m0thyj avatar Jul 27 '23 13:07 t1m0thyj