allow/deny directives not working
"OpenSSH for Windows" version OpenSSH_for_Windows_8.1p1, LibreSSL 2.9.2
Server OperatingSystem Windows Server 2019 Standard 10.0.17763.1158
Client OperatingSystem multiple openssh versions on multiple GNU/Linux versions
What is failing allow/deny directives
I've tried everything i could think of. Double quotes, wildcards, local users, every format of domain user imaginable, case sensitivity. There is nothing relevant in debug log, it just allows everyone to login, like it's no big deal.
This is relevant portion of my install script. I'm not doing any changes to default configuration.
#Download and install
$url = "https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip"
$zipfile = "C:\winssh.zip"
$outpath = "C:\Program Files"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
Invoke-WebRequest -Uri $url -OutFile $zipfile
Invoke-Unzip $zipfile $outpath
Remove-Item $zipfile -force
. $outpath\OpenSSH-Win64\install-sshd.ps1
#Add firewall rule
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
#Enable the openssh server services
Start-Service sshd
#Set services to start Automatically
Set-Service -Name sshd -StartupType 'Automatic'
#Set default openssh shell to powershell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
This is relevant portion of my install script. I'm not doing any changes to default configuration.
Default configuration allows all the users.
Please note any changes to $env:programdata\ssh\sshd_config requires sshd service restart (net stop sshd; net start sshd).
Sorry, i wasn't clear. I appended deny directive, eg DenyUsers testuser?ad.contoso.com, restarted sshd service and tried to login. Unfortunately it was successful.
@sabsamu - Please refer https://github.com/PowerShell/Win32-OpenSSH/wiki/sshd_config. It should be in "DenyUsers contoso\admin" format.
Like i said in the original post, i've tried every format i could think of. [email protected], ad.contoso.com\testuser, ad.contoso.com?testuser.
@sabsamu - We don't have normalization logic to accept different formats in sshd_config. We accept only contoso\testuser format i.e., shortdomainname/username. If this doesn't work then look at the sshd server side logs. Please follow instructions here to enable file based logging (easy to debug instead of ETW logging).
Thanks. I'l try and will report later.
Problem solved by two hashes. There is an Match block at the end of the default sshd_config that effectively invalidates anything appended to the end of file.
Problem solved by two hashes. There is an Match block at the end of the default sshd_config that effectively invalidates anything appended to the end of file.
thanks!! you save my half a day!