1

I have installed Cygwin with Apache, PHP, Mercurial, MYSQL, OpenSSH, PYTHON

I have updated sshd_config to chroot jail to access user-defined folders

example:

Match group sftp_users

ChrootDirectory /home/%u

SSH / SFTP works fine as I wanted.

After my connection to SSH, I get bash. There if I want to run any command like 'dir, hg, mysql, whatever' I simply get command not found

googling for days I tried below steps

  1. copying all files from C:/cygwin/bin to 'C:/cygwin/home/username/bin' and similarly dev,etc,lib,sbin,tmp,usr,var - this actually gives me different error something like error while loading shared libraries
  2. I tried updating on fstab like C:/cygwin/bin /bin ntfs binary 0 0 even that didn't make any change in my SSH connection command
  3. I tried adding path while making the SSH connection like plink.exe ssh -pw xxx username@hostname -v C:/cygwin/bin/python and I also tried plink.exe ssh -pw xxx username@hostname -v ../bin/python
  4. If I change sshd_config to its default, somehow the command works but I get wired output similar to the image below Command prompt response after plink SSH connection-wired

help me this could save my life.

  • It sounds like your Environment Path is empty. What happens when you run echo $PATH in the chroot? – zymhan Aug 28 '18 at 18:17
  • I have them all /usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/usr/bin:/home/myproject/bin:/home/myproject/lib – yellowandred Aug 29 '18 at 8:40
  • What are you trying to achieve that can't be addressed with file/folder permissions? You shouldn't be blindly copying "everything" into a chroot environment. – roaima Aug 31 '18 at 6:43
  • I tried copying everything in to chroot environment, but I am getting 'error while loading shared libraries' this error for all the commands, including commands like 'dir, ls, ldd, python' – yellowandred Aug 31 '18 at 6:48
  • I can see what you did. Why do you want a chroot environment? – roaima Sep 1 '18 at 16:46
0

Cygwin provides a dll that remaps Linux and POSIX calls to Windows API calls. Tools like chroot depend on having a proper Linux userspace and do not map nicely when using workaorunds like cygwin - although if you really want to do this it's possible, see here for what might be required.

What I'd recommend instead is using a real Linux userspace along with the newer Windows Subsystem for Linux. This provides a real Linux-compatible kernel interface supported by Microsoft, along with the real Linux userspace you'd get on a normal Linux system. The tools you mentioned should all work nicely in that setup, chroot and all.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.