Summary
=======

I have managed to do the following in NTemacs & cygwin:

- start emacs under ssh-agent
- run ssh-add under a *shell* buffer to add my public key to the
  agent
- ssh into a remote machine (using ssh-agent to handle
  authentication) under a *shell* buffer.

I think I can get tramp to work if I can get it to run `/bin/bash
-i' instead of `/bin/sh'.  Kai or David, would you be able to
tell me how to do this?  I tried a simple substitution on the
`su' method, but that didn't work.

Description
===========

Evidently, some changes were made to the TTY handling in cygwin
somewhere between B19 and now.  I recall being able to `M-x
ansi-term' with older releases of cygwin, but it doesn't work
now.

Anyway, the result of the changes in TTY handling is that ssh
will no longer let Emacs convince it that it is running in a
tty (as I believe it once would).

To circumvent this, ssh-agent /must/ be used to use ssh within
emacs.  I start emacs from within a cygwin bash shell like this:

  $ ssh-agent emacs

My startup files contain the following code:

   (cond ((eq system-type 'windows-nt)
       (setenv "SHELL" "c:/cygwin/bin/bash")
       (setq shell-file-name "bash")
       (setq shell-command-switch "-c")))

Once emacs is running, I `M-x shell' and in the *shell* buffer
type `ssh-add'.

I've had to create my own ssh-add script
(which I put in ~/bin):

--- begin ssh-add ---
#!/bin/sh

# ssh-add script for working under NTEmacs
# -- Mark A. Hershberger <[EMAIL PROTECTED]>

SSH_ASKPASS=get_line
DISPLAY=${DISPLAY:-localhost:0}
export SSH_ASKPASS DISPLAY

/usr/bin/ssh-add $*
--- end ssh-add ---

(Of course, you may want to name it something besides ssh-add.)

This calls get_line which simply echos back what is
typed in for the benefit of the calling process:

--- begin get_line ---
#!/bin/sh

read a
echo $a
--- end get_line ---

(Note that there are no stty calls here nor prompting so you may
want to try `M-x send-invisible'.  This is quite kludgy and I
will probably end up writing (or finding) a short Perl/Tk
replacement for them.)

(You may want to try to get agent authentication working outside
of emacs first.  See http://mah.everybody.org/docs/ssh for help.)

Once the agent is handling authentication, you should be able to
use ssh to access remote machines without being prompted for a
password.

Within a *shell* buffer, type `ssh user@machine bash -i'.  This,
of course, assumes that you have bash installed on your remote
machine.  The `-i' is required to tell bash to allocate a tty
(and give you a shell prompt) despite the fact that it does not
see that you have a tty on your end.

If you get this far, you may be interested in Noah Friedman's
ssh.el which provided directory tracking with ange-ftp.  (I have
a copy with patches that supports dir-tracking via tramp @
<http://mah.everybody.org/hacks/ssh.el.txt>.  I've sent this to
Noah and he seems interested but has not yet integrated it.)

Conclusion
==========

Ok, so this is where someone jumps in and tells me how to get a
tramp method with `bash -i' as the shell.  I think that is the
final piece to getting tramp working on NTEmacs with cygwin.

Mark.

-- 
                      ommnes exeunt in mysterium
                     All Things Lead into Mystery

Reply via email to