简体   繁体   English

Emacs tramp模式编辑中的密码

[英]Passwords in Emacs tramp mode editing

I'm using emacs tramp mode to remotely edit files over ssh. 我正在使用emacs tramp模式通过ssh远程编辑文件。 The problem is that every time I save the file I'm editing I have to enter my user password. 问题是每次我保存我正在编辑的文件时我都要输入我的用户密码。 I find that very annoying. 我觉得很烦人。 How can I write my password only once / editing session? 如何只编写一次/编辑会话密码?

Ah, from the tramp docs on password caching you can set: 啊,从密码缓存的tramp文档中你可以设置:

(setq password-cache-expiry nil)

which requires the package password-cache.el . 这需要包密码-cache.el

Also, in the tramp sources, it mentions reading the ssh-agent(1) man page, which shows how to set it up so that you don't have to re-enter passwords (inside, or outside of Emacs): 此外,在tramp源代码中,它提到了阅读ssh-agent(1)手册页,其中显示了如何设置它以便您不必重新输入密码(在Emacs内部或外部):

There are two main ways to get an agent set up: The first is that the agent starts a new subcommand into which some environment variables are exported, eg ssh-agent xterm &. 设置代理有两种主要方式:第一种方法是代理启动一个新的子命令,其中导出一些环境变量,例如ssh-agent xterm&。 The second is that the agent prints the needed shell commands (either sh(1) or csh(1) syntax can be generated) which can be evalled in the calling shell, eg eval ssh-agent -s for Bourne-type shells such as sh(1) or ksh(1) and eval ssh-agent -c for csh(1) and derivatives. 第二个是代理打印所需的shell命令(可以生成sh(1)或csh(1)语法),这些命令可以在调用shell中进行评估,例如eval ssh-agent -s用于Bourne类型的shell,例如对于csh(1)和衍生物,sh(1)或ksh(1)和eval ssh-agent -c

(setq password-cache-expiry nil)

In addition to Trey Jackson's solution , there are a few more ways you can choose: 除了Trey Jackson的解决方案 ,您还可以选择以下几种方式:

  • If you're on a *nix system, you can mount the remote directory with FUSE/SSHFS , and therefore you can edit files as they were on the local file system. 如果您使用的是* nix系统,则可以使用FUSE / SSHFS安装远程目录,因此您可以编辑本地文件系统上的文件。

  • Use SSH public key authentication . 使用SSH公钥认证

Using public key (RSA) authentication is more secure and much more convenient. 使用公钥(RSA)身份验证更安全,更方便。 On a GNU/Linux system (and maybe others, I don't know) you typically would unlock your private key once per login session with a password and then use it. 在GNU / Linux系统(以及其他人,我不知道)上,您通常会在每次登录会话时使用密码解锁您的私钥,然后使用它。

使用SSH公钥认证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM