Emacs / CVS / OpenSSH:防止密码弹出

发布于 2024-09-09 09:34:32 字数 337 浏览 11 评论 0原文

我在我的 Ubuntu 上网本上以全屏模式使用 GNU Emacs。当我编辑受版本控制的文件并点击 Cx vv 提交最新更改时,将打开一个 OpenSSH 弹出窗口,并询问我存储库所在服务器的密码。

不幸的是,由于全屏模式,弹出窗口不会出现在前面,我无法输入密码。但它仍然是模态的,所以我也不能返回 emacs,或者离开全屏模式(或者做其他任何事情,比如 Cg)。我基本上被困住了。

作为一名 emacs 用户,我发现弹出窗口的想法无论如何都令人厌恶;-) 所以理想情况下,我希望被要求提供迷你缓冲区中的 ssh 密码。我该如何调整我的设置才能实现这一目标? (我更喜欢每次都输入密码,而不是在 ~/.ssh/ 中存储密钥对)。

I'm using GNU Emacs on my Ubuntu netbook in fullscreen mode. When I edit files that are under version control and hit C-x v v to commit the latest changes, an OpenSSH popup window will open and ask me for my password for the server on which my repository lives.

Unfortunately, because of the fullscreen mode, the popup window will not come up front and I cannot enter my password. But it's still somehow modal, so I also can't go back to emacs and, say, leave fullscreen mode either (or do anything else, like C-g). I'm basically trapped.

As an emacs user, I find the idea of popup windows disgusting anyway ;-) so ideally, I'd like to be asked for the ssh password in the minibuffer. How can I tweak my setup to make that happen? (I prefer to type in my password every time instead of storing a keypair in ~/.ssh/).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

本王不退位尔等都是臣 2024-09-16 09:34:32

您可以在启动 emacs 之前(或在另一个 shell 中)使用 ssh-agent

You could use ssh-agent before launching emacs (or in another shell).

皇甫轩 2024-09-16 09:34:32

我在这里进行推测,因为我在 Emacs 中既没有使用 CVS 也没有使用 vc,但是我推测 Emacs 正在向适当的程序执行提交,并且密码提示完全是 Emacs 外部的东西。所以我怀疑你想要做的是首先找出需要哪些选项来从没有 Emacs 的 shell 进行无 GUI 提交,然后修改 vc-checkin-switches (或定义 vc-cvs-checkin-switches)在 Emacs 中进行匹配(请参阅 defun vc-switches)。

I'm speculating here, as I neither use CVS or vc within Emacs, however I presume that Emacs is shelling out to the appropriate program to perform the commit, and the password prompt is something entirely external to Emacs. So I suspect what you want to do is firstly find out which options are needed to do a GUI-less commit from your shell without Emacs, and then modify vc-checkin-switches (or define vc-cvs-checkin-switches) in Emacs to match (see defun vc-switches).

耀眼的星火 2024-09-16 09:34:32

这可能是 ssh-askpass 程序启动的,我认为它会查看 DISPLAY 环境变量来决定如何请求密码。如果设置,它会弹出一个图形窗口,如果没有,它会询问 TTY。

如果 vcs 子系统检测到何时向用户请求密码(这很可能),那么您可能可以取消设置子进程的 $DISPLAY:

(setenv "DISPLAY" nil)

不过,这可能会产生其他负面影响,因此还请查看“man ssh-askpass” “以防万一有什么帮助。

(免责声明:我个人使用基于 ssh-agent 的解决方案,我强烈推荐。)

It's probably the ssh-askpass program kicking in, which I think looks at the DISPLAY environment variable to decide how to request the password. If set, it pops up a graphical window, and if not, it asks the TTY.

If the vcs subsystem detects when passwords are requested from the user (which is likely), then it's possible that you can unset $DISPLAY for subprocesses:

(setenv "DISPLAY" nil)

This might have other negative side-effects, though, so also check out "man ssh-askpass" in case something there might help.

(Disclaimer: I personally use a solution based on ssh-agent, which I strongly recommend.)

挽你眉间 2024-09-16 09:34:32

您可以让 ssh 通过现有连接多路复用与服务器的所有新连接。这意味着只要您打开了 ssh 连接(例如在 shell 中),到同一远程主机的新连接就不会要求输入密码。我使用

Host *
    ControlPath ~/.ssh/master-%r@%h:%p
    ControlMaster auto
    ServerAliveInterval 30

~/.ssh/config 来设置它。

You can get ssh to multiplex all new connections to a server through existing connections. This means that as long as you have opened an ssh connection (say in a shell) new ones to the same remote host will not ask for a password. I use

Host *
    ControlPath ~/.ssh/master-%r@%h:%p
    ControlMaster auto
    ServerAliveInterval 30

in ~/.ssh/config to set this up.

楠木可依 2024-09-16 09:34:32

在研究我的主要答案(上面)时,我遇到了 emacs 的 psvn 。有关更多详细信息,请参阅此问题/答案:SVN for Emacs:如何设置作者姓名和保存密码?

我想你可能也会喜欢了解 psvn,但我认为关于在 SSH 上设置 PreferredAuthentications 值的那个更直接适用对于你最初提出的问题。

While researching my main answer (above), I came across psvn for emacs. See this SO question/answer for more details: SVN for Emacs: how do you set author name and save password?

I thought you might also appreciate knowing about psvn, but I think the one about setting the PreferredAuthentications value on SSH is more directly applicable to the question you originally asked.

童话 2024-09-16 09:34:32

尝试在您的环境中以某种方式设置它:

export CVS_RSH='ssh -o PreferredAuthentications="password"'

这应该让它停止尝试公钥身份验证,这也将抑制图形 ssh-askpass 的显示。这是通过指定 CVS 将用于连接到远程服务器的 SSH 命令来实现的。请注意,这将适用于从您设置环境变量的上下文运行的所有 CVS 命令。

您可能还想在 ~/.ssh/config 中进行设置。您可以单独为每个主机设置选项。 这是一个大致显示如何操作的页面,不过是为了强制进行公钥身份验证。请注意,这将影响您的用户帐户的所有 SSH 使用,而不仅仅是 CVS。这很可能就是您正在寻找的,因为您似乎更喜欢避免公钥身份验证。以下是您在 ~/.ssh/config 中添加的块的示例:

Host cvs

  Hostname cvs.your.corp
  User yourCVSusername
  PreferredAuthentications password

或者,您可以将 Host cvs 更改为 Host cvs.your.corp< /code> 如果您现有的访问方式使用 FQDN 而不仅仅是主机名。

最后,您可以将您的 ~/.ssh/config 文件仅包含这一行(或将其添加到现有行的顶部):

PreferredAuthentications password

这将使该首选项适用于与远程的所有 SSH 连接主机。

祝你好运。我希望这能让您摆脱模式对话框的陷阱。

Try setting this in your environment somehow:

export CVS_RSH='ssh -o PreferredAuthentications="password"'

That should get it to stop attempting publickey authentication, which will also suppress the display of the graphical ssh-askpass. This works by specifying the SSH command that CVS will use for connecting to the remote server. Please note that this will apply to all CVS commands run from the context in which you set the environment variable.

You may also want to look into setting it up in your ~/.ssh/config. You can set options for each host separately. Here's a page that roughly shows how, although for forcing publickey auth. Please note that this will affect all SSH usage for your user account, not just for CVS. That may very well be what you're looking for, since you seem to prefer avoiding publickey auth. Here's an example of the block you'd add in ~/.ssh/config:

Host cvs

  Hostname cvs.your.corp
  User yourCVSusername
  PreferredAuthentications password

Alternately, you could change Host cvs to Host cvs.your.corp if your existing means of accessing this uses a FQDN instead of just a hostname.

Lastly, you could have your ~/.ssh/config file by just this one line (or add it to the top of your existing one):

PreferredAuthentications password

That will make the preference apply to all SSH connections to remote hosts.

Best of luck. I hope this gets you out of the modal dialog trap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文