Problems Accessing VMs remotely Using Cygwin on XP

Discussions related to using VirtualBox on Windows hosts.
Post Reply
pressurepoint
Posts: 7
Joined: 24. Sep 2007, 00:46
Location: SC
Contact:

Problems Accessing VMs remotely Using Cygwin on XP

Post by pressurepoint »

I am loving the command line features of vboxmanage. My problem is that when I ssh into my host from work in order to start a machine, the machine is not 'there'. In other words when I use the command
./vboxmanage list vms
I get nothing. Same if I try and start any of the vms - I get an error saying they do not exist.
However, if I use the ssh server freesshd, which 'taps' into the windows command line, everything comes up. Same if I ssh localhost from cygwin within the host machine.
I have tried to copy the .virtualbox directory and the virtualbox.xml file into my cygwin home directory (c:/cygwin/home/me) to no avail. I started to change some permissions but figured as a newb venturing into new territory I would ask here before using my usual method of breaking things then figureing them out as I put them back together!
I could just stick with freesshd, but I really like cygwin and the openssh server and it forces me to use and learn unix commands.
Host: Windows XP Pro
Program file: C:/program files/innotek virtualbox/
xml file: C:/ documents and settings/.virtualbox/

Also, I can cd to the xml file and even pull it up in vim.

Thanks!!!!!
whiter
Posts: 3
Joined: 15. Oct 2007, 13:32

Post by whiter »

I have the same problem. Haven't managed to make cygwin work with VirtualBox yet. However a suggested workaround to keep cygwin working AND to use freesshd (best of both worlds!!) is to arrange it so that freesshd service is started manually only, and point its service at some other port, for localhost access only. (No firewall issues!)

Then once into your cygwin ssh from your remote location, use the 'sc' command to start the freesshd service and ssh into it via localhost at the chosen port. I have chosen port 23 since I don't use telnet. From cygwin that's 'ssh [username]@localhost -p 23'

This means two logons in a row to get to virtualbox, but most of the above can be automated by scripting making it quick to achieve.

Hope this helps!
pressurepoint
Posts: 7
Joined: 24. Sep 2007, 00:46
Location: SC
Contact:

thanks!!

Post by pressurepoint »

Yes, that does help. I have found freesshd to not work so well, with console problems and all, but simply using it as a portal to control virtualbox works for me!

Thank you also for the SC command - I was not aware of that one. Always nice to learn a useful unix command!

Thanks again for taking the time to answer.
whiter
Posts: 3
Joined: 15. Oct 2007, 13:32

Problems Accessing VMs remotely Using Cygwin on XP

Post by whiter »

You're welcome, glad it's of some use. BTW 'sc' is not unix, although I can see why anyone might think so, given such a brief filename typical of unix commands.

In fact it is a native Windows NT Series console app which I think stands for "service control". Starting and stopping services from the command line in Windows can also be done with the "net" command.

Fortunately cygwin seems to cope with most Windows command line apps rather well - at least I thought so until I came across the VirtualBox command line tools. This is something Innotek may want to consider, since cygwin sshd is widely used, popular and reliable.

Best wishes
whiter
Posts: 3
Joined: 15. Oct 2007, 13:32

Problems Accessing VMs remotely Using Cygwin on XP

Post by whiter »

Not wishing to be defeated by this, I have kept at it and finally found a solution for firing up vbox command line tools that appears to work entirely from within cygwin ssh without any need for freessh. The root of the problem would appear to be a combination of unexpected environment variables and lack of interaction with the desktop.

1) You need to enable the sshd service to be interactive with the desktop - I suspect this may be because the vbox server has hidden windows which the system nevertheless considers interactive.

Within computer management - services, go to cygwin sshd, stop it, tick "allow service to interact with the desktop" from the logon tab, and restart the service.

2) You need to establish a batch file which replaces all of the cygwin environment variables with ones expected in the native windows environment before calling the vbox command line tools from within the same batch file. It is likely that the one or two 'problem' environmental variables could be traced and only these changed, but I didn't bother to do a trial and error hunt - it is much easier to replace the lot!

Best way - from the cygwin ssh when logged into the sshd server machine, do a "set > [somefile.txt]" which will dump all the cygwin variables into a file. Do the same into another file from a native cmd prompt on the sshd server machine. Use something like MS Word with good find/replace facilities to edit the two files so each line in the
first cygwin file now reads "set [name of variable]=" thus 'unsetting all the cygwin variables. Edit the file you have output from the cmd prompt by just adding "set " at the front of each variable. Combine all the lines into a batch file so that all the 'unset' commands come first followed by the ones which set the windows environment.

Now add to the bottom of the .bat file any required commands, in normal windows command line format, to change to the vbox directory and run the command line tools. Remember these must always be run from WITHIN the batch file because once you exit, the variables are lost, and cygwin reverts back to its own environment which being unix based is not entirely compatible with windows apps.

You can run any batch file from within a cygwin ssh session by 'cd' to its directory, then run:

"./[name of file including .bat]"

So, in summary, your finished batch file should look something like this:-

set variable1=
set variable2=
.
.
...(commands to unset cyg variables)
.
.
set variablea=valuea
set variableb=valueb
.
.
...(commands to set win native variables)
.
.
cd "c:\program files\innotek virtualbox"
vboxvrdp -startvm "Windows XP"
Post Reply