Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
The startxwin.bat that is shipped with the cygwin version of XFree86 by default starts X in multiwindow mode and starts an xterm that is connected to your cygwin install. Querying a remote display manager is not possible when using the -multiwindow mode but it is easy to create simple .bat files that can launch programs on a remote machine (or coLinux machine)
I have chosen to use ssh to provide this ability but some may ask why ssh with all the extra encryption overhead when conecting within the same machine.
- It's easy. No display managers or xdmcp to configure and no extra security needed with the r commands to configure.
- This method can also be used to run programs on remote machines across an insecure network.
- It's there. I'm sure many of you at least copied your first few files to the coLinux image with scp just because sshd was already up and configured.
There are methods based on the Berklee r commands but I have not looked into this yet. I like many others consider the r commands to be legacy and have not devoted much time to learning them because ssh has provided for all the needs that I would have for them. For those who would like to look into this see rstart and rstartd in X11R6/bin.
For this discussion 192.168.0.2 will be the address of the coLinux host please substitute your IP address.
The first thing you want to do is make sure sshd is running on your coLinux and you can use it.
The first time you log in with ssh it will ask you if you want to add it to your known host list, please do so.
ssh -X 192.168.0.2 /usr/X11R6/bin/xterm
If you have different user names on your coLinux and cygwin you will need the -l username switch
ssh -X -l [[coLinuxusername]] 192.168.0.2 /usr/X11R6/bin/xterm
If this does not work you will need to enable X forwarding on your sshd so check the file /etc/ssh/sshd_config and make sure the X11Forwarding line is not commented and set to yes then restart sshd or restart coLinux and try agian. In addition, check that xauth is installed in coLinux, and the DISPLAY variable is set before calling ssh.
This should work but it will ask you for the password every time this could be anoying or cause problems when trying to do this from a gui. So we want to use public key authentication to make the conection. So create a key pair with ssh-keygen and add the public key to your /.ssh/authorized_keys file in coLinux
for example in cygwin
cd ~~/.ssh ssh-keygen -t rsa
It will ask you for a password to protect the key. This is generaly a good Idea but for a password protected key you will need an agent that can ask you for the password with the windows gui the first time it is needed each session. So for now I sugest leaving the password blank. I will add some info on using an agent at another time.
You will now have two new files id_rsa and id_rsa.pub. The latter is your public key this needs to be transfered to your authorized_keys file on your coLinux host.
scp id_rsa.pub firstname.lastname@example.org:/home/[[yourHomeDir]] ssh 192.168.0.2 cat id_rsa.pub >> ./.ssh/authorized_keys
Now you need to restart sshd this is different on different distros so If you are not sure how just shutdown and restart coLinux.
In the cygwin xterm you should now be able
ssh -X 192.168.0.2 /usr/X11R6/bin/xterm
and get an xterm running on colinux without needing to enter a password.
Now we can create a .bat file to do everything for us.
rem @echo off SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% ps | grep XWin if errorlevel 1 call startxwin.bat run c:\cygwin\bin\ssh -X 192.168.0.2 /usr/X11R6/bin/xterm
Save this as coLinuxXterm.bat and make sure windows didn't add any hidden extensions to it. Also if you copy and paste from here check for spaces that may have been added to the ends of lines.
Run the .bat file and you should have an xterm that is running on coLinux. If X was not currently running under cygwin then startxwin.bat will be run. Remember that startxwin.bat also starts a cygwin xterm so you may wish to comment out the line
run xterm -sl 1000 -sb -rightbar -ms red -fg yellow -bg black -e /usr/bin/bash -l
you could then create a new file called cygwinXterm.bat
rem @echo off SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% ps | grep XWin if errorlevel 1 call startxwin.bat run xterm -sl 1000 -sb -rightbar -ms red -fg yellow -bg black -e /usr/bin/bash -l
and use this to launch a cygwinXterm. This is a good idea any way because it provides an easy way to launch multiple cygwin xterms.
You can create shortcuts to these .bat files and place them in the start menu or launcher or on the desktop.
One possible problem with this Is that the .bat files only check to see if X is running they do not verify that it is running on localhost:0 so if you use scripts that launch other instances of X or you somehow get more than one going and then stop the one running on :0 this will not work. I may add an update to handle this situation at another time.
Another thing of intrest is that there seems to be a yet undoumented menu feature in the X icon in the taskbar if you place this file [.XWinrc || http://www.msu.edu/~huntharo/xwin/devel/server/example.XWinrc ] in your cygwin home directory it will add the menu. ssh -X comands can be added to this file to add them to the menu as well. This file is an example that I found on the screenshots page of Cygwin/X.
MassTranslated on 25 Dec 2004.
MassTranslated on Sun Apr 23 17:36:33 UTC 2006