如何配置 Mercurial 进行推送而不通过 ssh 询问我的密码?
我在项目中使用 Mercurial,每次通过 ssh 将新的变更集推送到服务器时,它都会要求我输入密码。
那么如何配置mercurial在不询问密码的情况下进行推送呢?
我在 Ubuntu 9.10 上工作
I use mercurial in my project, and every time I push new changesets to the server by ssh, it ask me for a password.
Then how to config the mercurial to push with out asking password?
I works on Ubuntu 9.10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Linux 和 Mac 上,使用
ssh-agent
。man ssh-keygen
)~/.ssh/id_dsa.pub
)复制到远程计算机,给出它是一个唯一的名称(例如myhost_key.pub
)~/.ssh/authorized_keys
文件中ssh-add
将密钥添加到钥匙串中您现在可以在此会话中使用任何远程
hg
命令,而无需进行身份验证。On Linux and Mac, use
ssh-agent
.man ssh-keygen
for details)~/.ssh/id_dsa.pub
) to the remote machine, giving it a unique name (such asmyhost_key.pub
)~/.ssh/authorized_keys
filessh-add
on your local workstation to add your key to the keychainYou can now use any remote
hg
commands in this session without requiring authentication.假设您使用的是 Windows,请阅读我的 Mercurial/SSH 指南。在帖子底部,您将找到有关如何使用 PuTTy 为您做这件事。
编辑:--这是我正在谈论的帖子的一部分(请记住,您需要在已加载密钥的情况下运行选美才能使其工作):
客户端:设置 Mercurial
如果您尚未安装 Mercurial,请确保使用默认设置在客户端计算机上安装 Mercurial。确保告诉安装程序将 Mercurial 路径添加到系统路径中。
客户端配置的最后一步是告诉 Mercurial 在使用 SSH 时使用 PuTTy 工具。 Mercurial 可以通过名为 .hgrc 的用户特定配置文件进行配置。在 Windows 上,它也可以称为 Mercurial.ini。该文件位于您的主文件夹中。如果您不知道主文件夹是什么,只需打开命令提示符并输入 echo %USERPROFILE% - 这将告诉您路径。
如果您尚未设置配置,则配置文件很可能不存在。所以你必须创建它。手动在主文件夹中创建一个名为 .hgrc 或 Mercurial.ini 的文件,然后在文本编辑器中打开它。这是我的部分的样子:
最后一行是关键,这是您确保其正确设置所需要的。我们告诉 Mercurial 使用 plink 程序。它也随 PuTTy 一起提供,是 PuTTY 程序本身在幕后执行的操作的命令行版本。我们还添加了一些参数:
客户现在已经准备好摇滚了!
Assuming you're using Windows, have a read of my Mercurial/SSH guide. Down the bottom of the post you'll find info on how to use PuTTy to do this for you.
Edit: -- Here's the part of the post that I'm talking about (bear in mind you'll need to have pageant running with your key already loaded for this to work):
Client: Setting up Mercurial
If you haven't already, make sure you install Mercurial on the client machine using the default settings. Make sure you tell the installer to add the Mercurial path to the system PATH.
The last step of configuration for the client is to tell Mercurial to use the PuTTy tools when using SSH. Mercurial can be configured by a user-specific configuration file called .hgrc. On Windows it can also be called Mercurial.ini. The file is located in your home folder. If you don't know what your home folder is, simply open a command prompt and type echo %USERPROFILE% - this will tell you the path.
If you haven't set up your configuration yet, then chances are the configuration file doesn't exist. So you'll have to create it. Create a file call either .hgrc or Mercurial.ini in your home folder manually, and open it in a text editor. Here is what part of mine looks like:
The last line is the key and this is what you need to make sure it set properly. We are telling Mercurial to use the plink program. This also comes with PuTTy and is a command-line version of what the PuTTY program itself does behind the scenes. We also add a few parameters:
The client is now ready to rock!
安装 PuTTY。
如果您使用的是 Windows,请在您喜欢的文本编辑器中打开
projectdir/.hg/hgrc
。将其编辑为如下所示:如果需要永远推送,服务器可能会尝试问您一个问题(但不会显示)。
运行此命令:
回答任何问题,然后再次尝试推送。
如果您使用的是 Bitbucket,请使用 puttygen 打开您的私钥,从顶部文本框中复制您的公钥,然后将其添加到您的用户帐户: https://bitbucket.org/account/user/USERNAME/ssh-keys/
Install PuTTY.
If you're on Windows, open
projectdir/.hg/hgrc
in your favorite text editor. Edit it to look like this:If it's taking forever to push, the server might be trying to ask you a question (but it's not displayed).
Run this:
Answer any questions, and then try pushing again.
If you're using Bitbucket, open your private key with puttygen, copy your public key out of the top textbox, and add it to your user account: https://bitbucket.org/account/user/USERNAME/ssh-keys/