Skip to content

Run as a Windows service

Harbor OnboardWindows administratorDescribes Onboard 0.58.0

Service mode runs the Harbor Onboard console (and Harbor Home) unattended: it starts when the machine boots, restarts after a failure, and serves HTTPS. Use it for a shared Harbor server.

  • An elevated PowerShell (Run as administrator). The certificate store, the http.sys bindings and the SYSTEM task all need it.
  • A verified release, extracted.
  • The tenant configured (the setup wizard, or Initialize-HarborConfig), and a service account whose secret SYSTEM can read, if the console should connect to the vault by itself. See the service account below.
Terminal window
cd C:\Harbor\harbor-onboard
Import-Module .\HarborOnboard\HarborOnboard.psd1
Install-HarborService -TrustRoot # loopback https service on port 8787
Get-HarborService # task state, port, TLS binding

Install-HarborService does this, in order:

  1. Reads the sign-in configuration first. If it cannot be read, it stops before changing anything (“Nothing was changed”).
  2. Deploys the code to %ProgramFiles%\Harbor (-InstallPath): a mirror of the module and its scripts, owned by Administrators. A SYSTEM task cannot run from a user’s profile folder, and code under %ProgramData%\Harbor (the data store) is moved out, because a file planted there would run as SYSTEM.
  3. Makes sure there is a way in. The SYSTEM console has no window to show a first-run setup code, so when no sign-in exists yet it asks for the emergency (break-glass) account here: a username, and a password typed into this console. Or pass -BreakGlassUser and -BreakGlassPassword.
  4. Checks the service account’s secret source and warns when SYSTEM will not be able to read it.
  5. Sets up HTTPS with Initialize-HarborTls, for port 8787 and Harbor Health’s port 8788. -TrustRoot also trusts the certificate on this machine.
  6. Reserves the URL in http.sys for SYSTEM.
  7. Registers the task Harbor Onboard Web: at startup, as SYSTEM, restart up to 3 times one minute apart, no time limit. It starts it and checks that the port answers.

Running it again is safe: it redeploys the code and replaces the task. That is also how you upgrade (see Upgrading).

When the task starts, the launcher refuses to load any code under its folder that is not owned by SYSTEM, Administrators or TrustedInstaller. It writes the reason to service-refused.log in that folder and exits. Re-run Install-HarborService to redeploy and reset the ownership.

Parameter Default Use
-Port 8787 The console port.
-Https $true -Https $false serves plain http (loopback only).
-TrustRoot off Trust the generated certificate on this machine, so local browsers show no warning.
-CertThumbprint none Use your own certificate (for example from your internal CA) instead of a generated one. It must be in LocalMachine\My with its private key.
-AllowRemote off Serve beyond this machine. Needs HTTPS and a sign-in.
-Hostname none The names clients use, with -AllowRemote: added to the certificate and to the allowed hosts.
-ConfigProfile the default profile Serve another tenant profile.
-BreakGlassUser, -BreakGlassPassword prompt The emergency account, when none exists yet.
-InstallPath %ProgramFiles%\Harbor Where the code is deployed.
-TaskName Harbor Onboard Web The scheduled task’s name.
Terminal window
Install-HarborService -AllowRemote -Hostname harbor.example.com -CertThumbprint <thumbprint>
  • A console reachable from the network must encrypt its traffic and require a sign-in: Harbor refuses -AllowRemote without HTTPS, and a demo or first-run console never counts as signed in.
  • Use a certificate your clients already trust (-CertThumbprint). A generated certificate is trusted only where you trust it yourself.
  • With single sign-on, the redirect URI changes to https://<hostname>:8787/auth/callback. Register it in the CyberArk Identity app (see SSO).
  • Open the port in Windows Firewall for the clients that need it, and nobody else.

The task runs as SYSTEM, and SYSTEM cannot read a secret you stored with DPAPI from your own Windows account. Choose a source SYSTEM can read:

Source How
SecretManagement (recommended) A SecretManagement vault that SYSTEM can open: Set-HarborServiceAccount -Kind oauth -ClientId <client id> -SecretSource secretManagement -SecretName <name> -Vault <vault> -Connect startup
DPAPI, saved by SYSTEM Run Set-HarborServiceAccount -SecretSource dpapi -Secret ... in a SYSTEM context. A blob saved by your account does not work.
Manual connect -Connect manual: an admin connects from the console with the secret typed in, after each restart.

See Service account & secret sources for the details.

Install-HarborService installs the Harbor Onboard console. It binds HTTPS for Harbor Health’s port too, so both consoles use the same scheme, but this release has no service installer for Harbor Health: start its console with Harbor-Health.cmd (or Launch-Harbor-Health.ps1) when you need it.

Terminal window
Get-HarborService # TaskName, task state, port up, TLS binding
Stop-ScheduledTask -TaskName 'Harbor Onboard Web'
Start-ScheduledTask -TaskName 'Harbor Onboard Web'

To remove the service, see Uninstall.

Symptom Fix
Install-HarborService needs an elevated (Administrator) console Run PowerShell as administrator.
Port not answering yet Check Get-HarborService and the task’s history in Task Scheduler. Look for service-refused.log in the install folder.
The console starts but the vault is not connected The service account’s secret is in a source SYSTEM cannot read. See above.
Refusing -AllowRemote without ... Add HTTPS, and create the emergency account or configure single sign-on.
Single sign-on fails after the move to a server Register the server’s redirect URI exactly: scheme, host and port.

Covers Harbor Onboard 0.59.0 / Harbor Health 0.22.0. On an older release? Upgrading and the release notes list what changed.