@@ -230,6 +230,26 @@ jobs:
230230 Write-Host "Client cert thumbprint: $($clientCert.Thumbprint)"
231231 Add-Content -Path $env:GITHUB_ENV -Value "CLIENT_CERT_SUBJECT=$($clientCert.Subject)"
232232
233+ - name : Create authorized_keys for testuser
234+ working-directory : ${{ github.workspace }}\wolfssh
235+ shell : pwsh
236+ run : |
237+ $pubKey = Get-Content "keys\hansel-key-ecc.pub" -Raw
238+ if (-not $pubKey) {
239+ Write-Host "ERROR: keys\hansel-key-ecc.pub not found"
240+ Get-ChildItem keys -ErrorAction SilentlyContinue
241+ exit 1
242+ }
243+ # Use comment 'testuser' so it matches the login user (authorized_keys format: "key-type key-data comment")
244+ $pubKey = ($pubKey -replace '\s+hansel\s*$', ' testuser').TrimEnd()
245+ $pubKey | Out-File -FilePath authorized_keys_test -Encoding ASCII -NoNewline
246+ if ((Get-Item authorized_keys_test).Length -eq 0) {
247+ Write-Host "ERROR: authorized_keys_test is empty"
248+ exit 1
249+ }
250+ Write-Host "Created authorized_keys_test with hansel public key (comment=testuser)"
251+ Get-Content authorized_keys_test
252+
233253 - name : Create wolfSSHd config file
234254 working-directory : ${{ github.workspace }}\wolfssh
235255 shell : pwsh
@@ -240,6 +260,18 @@ jobs:
240260 PermitRootLogin yes
241261 "@
242262
263+ # AuthorizedKeysFile: path must start with / for wolfsshd to treat as absolute (max 80 chars).
264+ $authKeysPath = (Resolve-Path "authorized_keys_test").Path
265+ $authKeysPattern = "/" + ($authKeysPath -replace '\\','/')
266+ if ($authKeysPattern.Length -gt 78) {
267+ Write-Host "WARNING: AuthorizedKeysFile path may exceed MAX_PATH_SZ (80): $($authKeysPattern.Length) chars"
268+ }
269+ Write-Host "AuthorizedKeysFile: $authKeysPattern"
270+ $configContent += @"
271+
272+ AuthorizedKeysFile $authKeysPattern
273+ "@
274+
243275 if ("${{ matrix.server_key_source }}" -eq "store") {
244276 # Get server cert subject from environment
245277 $serverSubject = (Get-Content env:SERVER_CERT_SUBJECT)
@@ -731,8 +763,7 @@ jobs:
731763 $errOut = Get-Content sftp_error.txt -Raw
732764 }
733765
734- # Success indicators: connection established, key exchange completed
735- # Failure indicators: connection refused, key exchange failed
766+ # Failure indicators
736767 if ($output -match "connection.*refused" -or $errOut -match "connection.*refused") {
737768 Write-Host "ERROR: Connection refused - server may not be running"
738769 exit 1
@@ -741,8 +772,16 @@ jobs:
741772 Write-Host "ERROR: Key exchange failed - cert store key may not be working"
742773 exit 1
743774 }
775+ if ($output -match "Couldn't connect" -or $errOut -match "Couldn't connect") {
776+ Write-Host "ERROR: SFTP could not connect (check authorized_keys, user, or server)"
777+ exit 1
778+ }
779+ if ($process.ExitCode -ne 0) {
780+ Write-Host "ERROR: SFTP client exited with code $($process.ExitCode)"
781+ exit 1
782+ }
744783
745- Write-Host "Test completed - key exchange appears to have worked "
784+ Write-Host "Test completed - key exchange and SFTP connection succeeded "
746785
747786 - name : Test SSH client connection
748787 working-directory : ${{ github.workspace }}\wolfssh
0 commit comments