[RESOLVED] Gitlab runner - ssh GetConsoleMode issue


I’m using a GitLab Windows runner for building my application and ssh deploying it to a Windows machine.

The .gitlab-ci.yml starts a powershell script, the powershell script opens an shh connection to a machine.

If I start the script from my local machine, it works.
If I start the script from the build machine manually, it works.

But when the GitLab runner starts the script at the build machine, the error GetConsoleMode on STD_INPUT_HANDLE failed with 6 shows up and the build flow locks. The execution neither stops, nor continues. The build will fail by timeout later.
As far as I can see, the command executes, but the ssh session doesn’t close.

I expect that there should be no difference between a manual script execution and a runner one. Is it possible to achieve?


Manual execution from build machine:

Manual execution from my local machine:

Runner execution from build machine:

Reproduce data

  • .gitlab-ci.yml file below
# .gitlab-ci.yml

  - execute

Release Runner:
  stage: execute
    - pwsh -File script.ps1 -login %%LOGIN%% -ip %%ADMIN%% -rsaPem %%RSAKEY%%
    - master
  • script.ps1 file below
# script.ps1

param (

$ErrorActionPreference = "Stop"
[console]::OutputEncoding = [Text.Encoding]::Utf8

$cmd = "powershell.exe -NoProfile -ExecutionPolicy ByPass -Command `"whoami`""

& ssh "$login@$ip" -n -T -i $rsaPem $cmd
  • Windows runner config.toml file:
# config.toml

concurrent = 1
check_interval = 0

  session_timeout = 1800

  name = "netCore-gitlab-runner"
  url = "https://gitlab.site.com"
  token = "TOKEN"
  executor = "shell"
  shell = "powershell"

Resolved with issue