all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* tramp and ssh-agent / ssh-add
@ 2008-03-30  0:53 Roland Winkler
  2008-03-30 11:12 ` Michael Albinus
       [not found] ` <mailman.9631.1206875452.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 18+ messages in thread
From: Roland Winkler @ 2008-03-30  0:53 UTC (permalink / raw)
  To: help-gnu-emacs

Usually when I have emacs running on a remote machine, I do this as
a subprocess of ssh-agent. Then when I establish ssh connections
via tramp, I want to make sure that I type my password only once via
ssh-add. What is the cleanest way to do that? Is there some support
from tramp for that? Right now, my home-made solution uses a
defadvice for tramp-open-connection-rsh, see the code below.
However, if tramp-open-connection-rsh is the right entry point for
what I want to do, it seems to me that a hook might be helpful. Or
am I missing something else?

Thanks,

Roland


(defun ssh-add-p ()
  "Return t if ssh identities known."
  (with-temp-buffer
    (call-process "/usr/bin/ssh-add" nil t nil "-l")
    (goto-char (point-min))
    (not (search-forward "The agent has no identities." nil t))))

(defun ssh-add (&optional password)
  "Add ssh passphrase."
  (interactive)
  (if (ssh-add-p)
      (if (interactive-p) (message "Passphrase already entered."))
    (with-temp-buffer
      (insert (or password (read-passwd "Passphrase: ")) "\n")
      (let ((process-environment (copy-alist process-environment)))
        (setenv "DISPLAY") ;; unset DISPLAY
        (call-process-region (point-min) (point-max)
                             "/usr/bin/ssh-add" t t nil))
      ;; Massage output
      (goto-char (point-min))
      ;; suppress "Enter passphrase for ...: "
      (search-forward ": " nil t)
      (let ((beg (point)))
        (goto-char (point-max))
        (skip-chars-backward " \t\n")
        (message "%s" (buffer-substring-no-properties beg (point)))))))

(defadvice tramp-open-connection-rsh (before ssh-add activate)
  "First call `ssh-add'."
  (if (string= "ssh" (ad-get-arg 1))
      (ssh-add)))


^ permalink raw reply	[flat|nested] 18+ messages in thread
* tramp and ssh-agent / ssh-add
@ 2008-03-30 16:16 Roland Winkler
  0 siblings, 0 replies; 18+ messages in thread
From: Roland Winkler @ 2008-03-30 16:16 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

I've discussed the following with Michael Albinus on help-gnu-emacs.

The starting point was that I like to run remote emacs sessions as a
subprocess of ssh-agent. When using tramp for file transfer, I need
then ssh-add. The general question is: what is the best way to
communicate from within emacs with the agent?

Right now, I am using a home-made solution that uses a defadvice for
tramp-open-connection-rsh, a function from tramp 2.0, but not
available anymore in tramp 2.1. A hook would be a cleaner
alternative, but again it appears rather limited. Michael pointed
out that not only there is also the gpg agent, but Gnome and KDE
have keyring managers, too, and it might be useful to have a general
interface that allowed one to communicate from within emacs with
these agents. (Personally, I do not know anything about Gnome and
KDE.) Then tramp could use this interface to call ssh-add when
needed, and other packages could use it in a similar way.

I'd greatly prefer such an approach over caching passwords.
(Currently, tramp uses password.el for this which comes from Gnus.)

What do you think?

Roland




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-04-07  8:56 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-30  0:53 tramp and ssh-agent / ssh-add Roland Winkler
2008-03-30 11:12 ` Michael Albinus
     [not found] ` <mailman.9631.1206875452.18990.help-gnu-emacs@gnu.org>
2008-03-30 12:28   ` Roland Winkler
2008-03-30 13:54     ` Michael Albinus
2008-03-30 14:25       ` Roland Winkler
2008-03-30 15:30         ` Michael Albinus
2008-03-30 15:38           ` Roland Winkler
2008-03-30 15:56             ` Michael Albinus
2008-04-01  0:17         ` Mike Mattie
     [not found]       ` <mailman.9640.1206887118.18990.help-gnu-emacs@gnu.org>
2008-03-31  7:44         ` Tim X
2008-03-31 10:26           ` Michael Albinus
     [not found]           ` <mailman.9696.1206959167.18990.help-gnu-emacs@gnu.org>
2008-03-31 21:04             ` Roland Winkler
2008-04-01  0:19               ` Mike Mattie
     [not found]               ` <mailman.9752.1207009209.18990.help-gnu-emacs@gnu.org>
2008-04-01  3:15                 ` Roland Winkler
2008-04-05  4:38               ` Tim X
2008-04-07  4:32                 ` Roland Winkler
2008-04-07  8:56                 ` Peter Dyballa
  -- strict thread matches above, loose matches on Subject: below --
2008-03-30 16:16 Roland Winkler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.