Howto: starting ssh-agent/keychain and launching remote apps

Peter Valdemar Mørch
Fri Apr 16 14:43:00 GMT 2004

Hi there,

I use xterms on remote machines, and really don't want to have to start 
a cygwin prompt every time. With the setup shown here, you can create a 
windows shortcut, that will ssh to and launch an app on a remote machine 
without any cygwin prompt and without any annoying dos boxes hanging 
around in the taskbar.

If anybody has gotten this to work in a simpler way, I'd love to hear 
about it. But in order to source the .keychain/<mach>-sh and then run 
ssh I have to run bash. Running bash gives a nasty dos box, unless I use 
7 lines of Visual Basic. Simpler suggestions? It has taken me a while to 
get it to work, and so I thought I'd post the howto here.

I'd like to write the documentation for this too (e.g. in "Displaying 
Remote Clients" in the UG), but would like first to hear if this is 
useful to anybody. If so, I'll write the docbook documentation and 
submit a more complete patch.

Until then, here is a patch to startxwin.bat. I want the ssh-agent 
(keychain) opened when the x-server is started, so I'm good to go 

Also, it describes in a REAME manner how to get a desktop icon working 

Here is the patch.

Mail breaks the lines of the patch. Here is a URL too:

--- startxwin.bat.orig	2004-04-16 13:43:06.129258200 +0200
+++ startxwin.bat	2004-04-16 14:20:00.064851500 +0200
@@ -145,6 +145,43 @@
  run XWin -multiwindow -clipboard

+REM Startup the keychain to hold your ssh private keys. This will allow
+REM you to ssh to remote hosts without being asked for a password.
+REM It requires that the keychain package is installed. It is found
+REM in Setup/Utils/keychain.
+REM First, set up your ssh keys so they work with ssh-agent and ssh-add.
+REM It works when you can do e.g. "ssh remotehost" and you are not
+REM asked for a password. Get this to work first in a normal cygwin prompt.
+REM Check out one of the howtos here:
+REM Once that is working, keychain will make sure the ssh-agent is started
+REM and the keys are added.
+REM Then you can create desktop shortcuts to remote hosts like this:
+REM Right click on the windows desktop, select New/Shortcut,
+REM and then enter a line like this in the field:
+REM %windir%\System32\wscript.exe c:\data\scr\quiet.vbs 
C:\cygwin\bin\bash.exe  --login -c "ssh -f -Y -A remotehost xterm"
+REM (Replace remotehost with the host name)
+REM quiet.vbs is written in Visual Basic, and its purpose is to avoid an
+REM annoying dos box that has no purpose. It must contain something 
like this:
+REM Set oShell = CreateObject ("Wscript.Shell")
+REM Set objArgs = WScript.Arguments
+REM ' Join and quote all the arguments....
+REM for each arg in objArgs
+REM         cmd = cmd & """" & arg & """" & " "
+REM next
+REM oShell.Run cmd , 0, 0
+REM \cygwin\bin\bash -c "keychain `ls ~/.ssh/id*|grep -v '\.pub$'`"
  REM Startup an xterm, using bash as the shell.

  run xterm -sl 1000 -sb -rightbar -ms red -fg yellow -bg black -e 
/usr/bin/bash -l

Peter Valdemar Mørch

More information about the Cygwin-xfree mailing list