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 [email protected] 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 [email protected]) 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.

2
  • Does it make a difference if you add -SessionOption (New-PSSessionOption -NoMachineProfile) to either Invoke-Command or Enter-PSSession? Commented Feb 23, 2022 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. Commented Feb 23, 2022 at 17:35

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.