![]() |
| Remote CLI SSH debug on Windows server does not from the IDE |
|
Site Admin
|
Thank you for posting this.
Could you check what `echo $0` returns in your terminal? On Linux, it prints the shell type (for example, bash). If you are using bash, it should normally work without issues. However, it's not a Linux environment. In any case, you can validate your project using the Project Settings Wizard. You can find this button in the Project Properties dialog. The wizard gathers information about PHP and the debugger on your server, then posts a diagnostic log. If it detects any known issues, it may also suggest possible fixes. You can reply here or in the ticket that you opened with support. |
||||||||||||
|
_________________ The PHP IDE team |
|||||||||||||
|
Hi Dmitri,
Yes, on an SSH Ubuntu, if I type `$echo $0`it will reply `-bash` on Windows SSH replies `$0`. Maybe if it about how to get information about the shell is running on windows `echo %SHELL%` which will reply `c:\windows\system32\cmd.exe` on Ubuntu `echo $SHELL` reply `/bin/bash` Do you think it needs to detect the shell that it's running? Do you think it needs a bash shell on windows? I have the Git SCM installed on the server which provides a bash shell. I could try to see if I can change the shell on the Windows OpenSSH server. However, it will be better if there is a solution without doing these hacks. I tried to run the wizard settings; all validations pass until arrive to validate the CLI, which does what I described before. If I skip this part and continue, save the project, I can without problem Debug HTTP, but not CLI. On a local installation (of the same projects), I can run the Wizard Settings complete without problems both HTTP and CLI. |
||||||||||||
|
|
|||||||||||||
|
Site Admin
|
it needs to detect the shell, otherwise it can’t reliably execute commands or interpret their output. It used to support cmd.exe, but I’m not sure what changed in Windows 22. Can you work with unix-compatible shells under Windows for now? Cygwin or may be similar alternatives. Git comes with a good shell too.
As of the Wizard, don't cancel it, give it at least 30sec |
||||||||||||
|
_________________ The PHP IDE team |
|||||||||||||
|
I currently I'm trying to change the shell from the OpenSSH server. I will let you know if I can change it and if that helps with the debugger.
When I am run the CLI debugger on the IDE, runs for 30 seconds until show a pop-up that has failed. The SSH terminal shows this: hxxps://postimg.cc/njyFhLL2 When I run the Wizard, it gets this: hxxps://postimg.cc/t19D8dNb Until it fails like this: hxxps://postimg.cc/sQhBcqGF |
||||||||||||
|
|
|||||||||||||
|
Ok I was able to change the Shell from `cmd.exe` to git `bash.exe`. It's a little better, it is able to submit commands but still end up with not debug. No sure why has to submit so many `echo "phped.21.0.0.21033"`. Here is the screenshot of the result.
hxxps://postimg.cc/5Y7NvMm3 Unfortunately, I cannot test if this works on Linux as I have no server with the debugger module installed. |
||||||||||||
|
|
|||||||||||||
|
Site Admin
|
Thank you for the update. We need to check how it works internally when running bash / MINGW on Windows.
The repeated echo "phped.21.0.0.21033" appearing on a single line may be related to differences in line endings. Windows does not handle \n correctly on its own and typically expects \r\n. Previously, we tested only with Cygwin and the native shell. To test compatibility with the native Windows shell, you could try using a Telnet connection instead of SSH. Windows servers come with Telnet service. Telnet client is built-into PhpED. You can give it a try. |
||||||||||||
|
_________________ The PHP IDE team |
|||||||||||||
|
Unfortunately, I will not be able to test it on Telnet as this server is on production and on public network. It will be a "no-no" from our security team. In the past because I couldn't install a reliable and affordable SSH server on windows, we ended installing PhpEd on the server and RDP only for the purpose of debugging. Since Windows 2022, OpenSSH is included on the installation of the OS. I have been installing it for remote debugging HTTP without issue. But until now that I have to debug a CLI script, I am finding this problem.
Now that I know that I can change the sell, I could see if I find a Cygwin bash shell for windows to test with it. Yes, on the `cmd.exe` shell it makes sense all those echoes are on one line, it output them until times out. But on `bash` shows them on different prompts while executing the same script from 3 to 30 times, depending on the mood. It continues with one `echo $0`, one `env` and it ends with 2 empty prompts. Stays here until times out. |
||||||||||||
|
|
|||||||||||||
|
Site Admin
|
For the purposes of PhpED development, we haven’t concidered Windows as a remote platform for PHP cli development, as it’s clearly not very popular in that role. I didn’t realize that, in your case, it is actually used in production. Of course, Telnet is not an option, and, by the way, it hasn’t been included as a Windows component since around Windows 8 or 10. We will improve support for Windows as a remote platform for CLI debugging in the next version.
Cygwin setup is straightforward. Download the Cygwin setup executable, run it, and select the openssh component for installation (it may offer multiple versions, including non-production debug or test builds). After installation, run cygwin.bat, in the the shell execute the ssh-host-setup command. If you don’t enable the isolation option, sshd will work as a service out of the box. With isolation enabled, it may require a few additional tweaks, if I recall correctly. |
||||||||||||
|
_________________ The PHP IDE team |
|||||||||||||
|
Site Admin
|
PHP CLI debugging works under Cygwin.
In my setup, all project files are stored remotely on the Windows server. Project root: [SFTP:win22] /cygdrive/c/Users/Dmitri/Documents/Projects Run target: remote server Remote root directory: C:\Users\Dmitri\Documents\Projects Terminal account: ssh-terminal-win22 PHP executable: /cygdrive/c/Users/Dmitri/AppData/Roaming/NuSphere/php83/php.exe Make sure there are no spaces in the path to php.exe I did not configure SSH port forwarding (tunneling) for debugging because the server is on the same local network. However, you may need to set up a tunnel if your server is on a different network. and Windows Firewall should explicitly allow ssh port for external connections. Below is power shell command I used
|
||||||||||||||
|
Last edited by dmitri on Thu Apr 02, 2026 6:47 am; edited 1 time in total _________________ The PHP IDE team |
|||||||||||||||
|
Sorry the delay, I was pulled on other projects.
Finaly, I have been able to dedicate time to test on Cygwin. I can say it works but it's somehow a convoluted procedure and still I have to debug the script twice to make it work. These are the steps. 1. Download and install the basic Cygwin 2. Edit the Registry add these String keys:
3. Test that I can remote SSH and get a bash shell 4. Test if can run "ls" command. If not, something is wrong loading the default profile (This was my first mistake by trying to load bash directly from "C:\\cygwin64\\bin\\bash.exe" and parameters "-i --login") 5. On PHPEd open the project that is remote. The tunnel should open without problem. 6. Change on "Run target" the "Php executable" to the cygwin format. In my case it is on the PATH so it should a simple "php", but I pointed it to the PHP that I have installed at "/cygdrive/C/4safecom/php/php" 7. The "Remote root directory" I have to leave it on Windows format, do not put it on Cygwin format. Because the PHP binary still is a windows version. 8. Open a CLI script and set a breakpoint. 9. Change Run mode to CLI and run on Debug mode. It will open a SSH tab, the first time it will show a lot of stuff of the ENV variable, 10. If it doesn't start debugging right away, press Cancel, do not close the SSH tab, run the debugger again. 11. Most of the times the second time start debugging right away. I think the problem that needs to run twice is due that cygwin needs to run the batch file instead of running the bash on SSH. So, it has to run CMD and then it switches to bash. As a sample, this is the output I get on the SSH window:
However, after doing this the SFTP doesn't work properly anymore. If I revert to "cmd.exe", it works. I have to install FileZilla Server to use FTPS instead. At the end, it should be way easier if the CLI debugging is aware how to run in the CMD instead of cygwin and bash. |
||||||||||||||||
|
|
|||||||||||||||||
|
Site Admin
|
I think you'd run sshd from cygwin if you're using cygwin. It runs cygwin's bash (or zsh if you will) without any problems or quirks and therefore wouldn't require to run twice and sftp would work too.
You also will find out that public keys for regular (non-Administrator) user authentication are working out of the cygwin box too. I couldn't find a way to set that with Win10's openssh component. I agree that cmd and openssh components on Win10+ should be preferred in your case. They were not available at the time when the feature was designed and developed, but telnet was. Now telnet is not available and we need to implement cmd based connector for windows. |
||||||||||||
|
_________________ The PHP IDE team |
|||||||||||||
| Remote CLI SSH debug on Windows server does not from the IDE |
|
||
|
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by


RSS2 Feed