0

I have PHP application to create user accounts in our Windows Active Directory. This application is running on Apache and Debian 11. I have LDAP only (because of some apps which are not supporting LDAPS), so I'm unable to set password directly from PHP. I'm trying to achieve this using powershell via ssh. I have installed latest versions 7.2 on both linux and domain controller. On DC I added OpenSSH server and turned firewall off. I've added the linux computer to trustedHosts on DC.

I'm able to connect to DC from remote computer via putty and it runs smoothly. When I use ssh@192.168.2.11 from linux server, it runs well too, however when I run something like this from linux server

Invoke-Command -ComputerName 192.168.2.11 -Credential $creds -Authentication Negotiate -ScriptBlock {Get-Process}

where $creds contains something like domain\lastname.firstname (also tried lastname.firstname@domain.com) and password, it takes from 2 to 5 minutes to execute this command. When I try Enter-PSSession and connect to DC, every single command take several minutes to execute, for example if I run Get-Date, it take another 2-5 minutes to execute. Even when I just hit enter without command, I can continue with the terminal again after 2-5 minutes.

I've tried it on Debian9,Debian11, Windows Server 2019 and 2022.

culter
  • 507
  • 2
  • 9
  • 16
  • Does it make a difference if you add `-SessionOption (New-PSSessionOption -NoMachineProfile)` to either `Invoke-Command` or `Enter-PSSession`? – Mathias R. Jessen Feb 23 '22 at 16:11
  • Hi Mathias, thanks for comment. There is no -NoMachineProfile switch for New-PSSessionOption on linux :( I have a "solution" already, I will create an answer. – culter Feb 23 '22 at 17:35

1 Answers1

0

I already solved it. There was no problem at all, at least for the task I want to achieve. I used putty to connect to Linux VM and then from there I tried to run these Powershell remote commands to connect to DC and it was extremely slow, as I described, but when I connected to Windows server with ssh command (outside of powershell), everything runs well, only the powershell commands were slow.

When I use VirtualBox console to connect to this Linux VM and not putty(ssh), everything is running smoothly. I need to run the powershell from PHP, so there is not needed to connect via ssh first, I used it just for testing and it cost me 2 days of labouring. I'm perfect fine with this soludion. Hope this helps someone.

culter
  • 507
  • 2
  • 9
  • 16