Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tramp and ssh-key passphrase

28 views
Skip to first unread message

lee

unread,
Feb 28, 2016, 1:16:29 PM2/28/16
to help-gn...@gnu.org

Hi,

is there a way to have tramp cache the passphrase of the ssh key I'm
using to edit a remote file --- or some other way which doesn't require
me to enter the passphrase all the time?

It's asking for the passphrase every time emacs wants to perform an
autosave, and I don't really want to turn off autosaving or to use a key
that doesn't require a passphrase.

I wouldn't mind defaulting to autosaving locally when editing remote
files, though. Maybe that can be done somehow?

The way it is kinda defeats the comfort of being able to edit remote
files ...


--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2015-09-26 on heimdali

Loris Bennett

unread,
Feb 29, 2016, 2:24:37 AM2/29/16
to
lee <l...@yagibdah.de> writes:

> Hi,
>
> is there a way to have tramp cache the passphrase of the ssh key I'm
> using to edit a remote file --- or some other way which doesn't require
> me to enter the passphrase all the time?
>
> It's asking for the passphrase every time emacs wants to perform an
> autosave, and I don't really want to turn off autosaving or to use a key
> that doesn't require a passphrase.
>
> I wouldn't mind defaulting to autosaving locally when editing remote
> files, though. Maybe that can be done somehow?
>
> The way it is kinda defeats the comfort of being able to edit remote
> files ...

Try setting up an SSH agent. That way you just have to enter the
passphrase once per session.

Cheers,

Loris

--
This signature is currently under construction.

Michael Albinus

unread,
Feb 29, 2016, 4:16:03 AM2/29/16
to help-gn...@gnu.org
lee <l...@yagibdah.de> writes:

> Hi,

Hi,

> is there a way to have tramp cache the passphrase of the ssh key I'm
> using to edit a remote file --- or some other way which doesn't require
> me to enter the passphrase all the time?

There is the recommendation to use ssh-agent, which is always good.

Another solution would be (setq password-cache-expiry nil)

Best regards, Michael.

lee

unread,
Mar 18, 2016, 4:03:57 PM3/18/16
to help-gn...@gnu.org
Thanks, I tried, and it only says


,----
| Could not add card ".ssh/[...]": agent refused operation
`----


when I try to add a key, so I killed it. The agent had been started
with


,----
| eval $(ssh-agent)
`----


in my .xinitrc.

This is awful because it requires me to exit the X session to get the
ssh-agent to work. I won't do much experimenting on this ...


--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali

lee

unread,
Mar 18, 2016, 4:03:57 PM3/18/16
to help-gn...@gnu.org
Michael Albinus <michael...@gmx.de> writes:

> lee <l...@yagibdah.de> writes:
>
>> Hi,
>
> Hi,
>
>> is there a way to have tramp cache the passphrase of the ssh key I'm
>> using to edit a remote file --- or some other way which doesn't require
>> me to enter the passphrase all the time?
>
> There is the recommendation to use ssh-agent, which is always good.
>
> Another solution would be (setq password-cache-expiry nil)

Cool, I'll try that because the ssh-agent doesn't work.

Jorge A. Alfaro-Murillo

unread,
Mar 18, 2016, 4:21:29 PM3/18/16
to help-gn...@gnu.org
lee writes:

> "Loris Bennett" <loris....@fu-berlin.de> writes:
>>
>> Try setting up an SSH agent. That way you just have to enter
>> the passphrase once per session.
>
> Thanks, I tried, and it only says
>
> ,---- | Could not add card ".ssh/[...]": agent refused operation
> `----

You are supposed to have a key in your .ssh, if not do something
like

#+BEGIN_SRC shell
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -o -a 100
#+END_SRC

You would then have to copy the content of id_rsa.pub into
~/.ssh/authorized_keys of the machine you want to login onto.

> when I try to add a key, so I killed it. The agent had been
> started with
>
> ,---- | eval $(ssh-agent) `----
>
> in my .xinitrc.
>
> This is awful because it requires me to exit the X session to
> get the ssh-agent to work. I won't do much experimenting on
> this ...

You should only start the ssh-agent once per session, that is the
whole point of it. Actually it should start automatically.

You can try:

#+BEGIN_SRC shell
killall ssh-agent
eval `ssh-agent -s`
#+END_SRC

Then do

#+BEGIN_SRC shell
ssh-add
#+END_SRC

right after you login. It will ask for the password of your id_rsa
key, and then let you connect for the rest of your session.

Best,
--
Jorge.


0 new messages