From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7083 invoked by alias); 11 Nov 2013 13:12:56 -0000 Mailing-List: contact cygwin-xfree-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-xfree-owner@cygwin.com Reply-To: cygwin-xfree@cygwin.com Mail-Followup-To: cygwin-xfree@cygwin.com Received: (qmail 7070 invoked by uid 89); 11 Nov 2013 13:12:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_20,RDNS_NONE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Nov 2013 13:12:54 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rABDClQx029884 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Nov 2013 08:12:47 -0500 Received: from mmyllyne.csb (vpn1-7-70.ams2.redhat.com [10.36.7.70]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rABDCjQV018627 for ; Mon, 11 Nov 2013 08:12:46 -0500 Message-ID: <5280D7CD.4040102@redhat.com> Date: Mon, 11 Nov 2013 13:12:00 -0000 From: Marko Myllynen Reply-To: myllynen@redhat.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Thunderbird/17.0.8 MIME-Version: 1.0 To: cygwin-xfree@cygwin.com Subject: x-app-open - open remote X app windows on Windows desktop with Cygwin Content-Type: multipart/mixed; boundary="------------070309020906050203050703" X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00007.txt.bz2 --------------070309020906050203050703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1757 Hi, FWIW, I've written the attached script to facilitate launching remote X applications on Windows desktop with Cygwin. I presume for most people on this list it does not provide anything new but its target audience is rather people who are not very familiar with Cygwin, Linux, X, or SSH and prefer using Windows, allowing them easily to run remote X applications just by clicking a desktop icon. In short, the script will start XWin and setup SSH keys with minimal user intervention allowing easy but secure use of remote X applications on Windows desktop. The complete installation instructions are as follows, this is a copy/paste from the script, after that one just needs to click on the newly created icon: # Installation instructions for Cygwin and this script: # # 1) Install from http://www.cygwin.com/ using 32 or 64-bit setup*.exe # 2) During installation, select at least these additional packages: # # keychain openssh psmisc xorg-server xterm # # 3) Place this script in C:\cygwin\bin # 4) Create a shortcut on Windows desktop with # a) "Start in" being the bin path 3) above # b) "Target" being # # C:\cygwin\bin\run.exe -p /bin /bin/sh -c "/bin/x-app-open host application" # # In case a user name needs to be specified use the form user@host. # I'm not a Cygwin packager and not planning to become one but if someone sees this valuable, creating an x-app-open Cygwin package with proper dependencies would allow making the second step above a bit more straightforward. But even by itself the script, now available in the list archives, has been helpful. Wrt to technical details, there might be a corner case or two when XWin is left behind but otherwise I'm not aware of any major issues with it. Thanks, -- Marko Myllynen --------------070309020906050203050703 Content-Type: text/plain; charset=UTF-8; name="x-app-open" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="x-app-open" Content-length: 2728 #!/bin/sh # # x-app-open - open remote X app windows on Windows desktop with Cygwin # # Copyright (C) 2013 Marko Myllynen # This program is free software; it is released under the GPLv3. # # Installation instructions for Cygwin and this script: # # 1) Install from http://www.cygwin.com/ using 32 or 64-bit setup*.exe # 2) During installation, select at least these additional packages: # # keychain openssh psmisc xorg-server xterm # # 3) Place this script in C:\cygwin\bin # 4) Create a shortcut on Windows desktop with # a) "Start in" being the bin path 3) above # b) "Target" being # # C:\cygwin\bin\run.exe -p /bin /bin/sh -c "/bin/x-app-open host application" # # In case a user name needs to be specified use the form user@host. # SSH_OPTS="-oBatchMode=yes -oConnectTimeout=20 -oStrictHostKeyChecking=no" # Launch XWin if not there already XPID=$(ps -ef | grep /bin/XWin | grep -v grep | awk '{print $2}') if [ "$XPID" = "" ]; then run cygstart --hide /bin/XWin :0 -clipboard -multiwindow XPID=$(ps -ef | grep /bin/XWin | grep -v grep | awk '{print $2}') fi export DISPLAY=$HOSTNAME:0 # Setup SSH keys if needed while [ ! -f "$HOME/.ssh/id_rsa" ]; do xterm +tb -T "Setting up SSH keys..." -e \ "echo Generating SSH keys, enter a new passphrase, at least 5 characters.;\ ssh-keygen -f \"$HOME/.ssh/id_rsa\" > /dev/null; \ echo Copying SSH public key to the remote host...; \ ssh-copy-id -i \"$HOME/.ssh/id_rsa.pub\" \ -oStrictHostKeyChecking=no $1 2>&1 | grep -v INFO" done # Add SSH keys to ssh-agent with keychain if needed [[ -f "$HOME/.keychain/$HOSTNAME-sh" ]] && \ . "$HOME/.keychain/$HOSTNAME-sh" > /dev/null 2>&1 ssh-add -l 2>/dev/null | grep -q "$HOME/.ssh/id_rsa" if [ $? -ne 0 ]; then cygstart --hide xterm +tb -T '"Loading SSH keys..."' -e "keychain -q \"$HOME/.ssh/id_rsa\"" sleep 3 while true; do sleep 1 pstree -aA | grep -q -- "[-]xterm +tb -T Loading SSH keys..." || break done [[ -f "$HOME/.keychain/$HOSTNAME-sh" ]] && \ . "$HOME/.keychain/$HOSTNAME-sh" > /dev/null 2>&1 fi # Do the actual work ssh $SSH_OPTS -X $1 "${@:2}" > /dev/null 2>&1 if [ $? -eq 255 ]; then # Connection failed, perhaps a new host, try to copy the key xterm +tb -T "Setting up SSH keys..." -e \ "echo Copying SSH public key to the remote host...; \ ssh-copy-id -i \"$HOME/.ssh/id_rsa.pub\" \ -oStrictHostKeyChecking=no $1 2>&1 | grep -v INFO" ssh $SSH_OPTS -X $1 "${@:2}" > /dev/null 2>&1 fi # Terminate XWin if no active connections left sleep 1 sessions=$(pstree -aA | grep "[s]h $0" | wc -l) if [ $sessions -le 2 ]; then /bin/kill $XPID > /dev/null 2>&1 ; /bin/kill -f $XPID > /dev/null 2>&1 fi --------------070309020906050203050703 Content-Type: text/plain; charset=us-ascii Content-length: 223 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://x.cygwin.com/docs/ FAQ: http://x.cygwin.com/docs/faq/ --------------070309020906050203050703--