如何在无需创建新密钥的情况下删除 SSH 密钥的密码? [英] How do I remove the passphrase for the SSH key without having to create a new key?

查看:37
本文介绍了如何在无需创建新密钥的情况下删除 SSH 密钥的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在笔记本电脑上创建新的 SSH 密钥时设置了密码.但是,正如我现在意识到的那样,当您尝试提交时这是非常痛苦的 (GitSVN) 在一小时内通过 SSH 多次发送到远程位置.

I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (Git and SVN) to a remote location over SSH many times in an hour.

我能想到的一种方法是,删除我的 SSH 密钥并创建新的.有没有办法删除密码,同时仍然保留相同的密钥?

One way I can think of is, delete my SSH keys and create new. Is there a way to remove the passphrase, while still keeping the same keys?

推荐答案

简答:

$ ssh-keygen -p

这将提示您输入密钥文件位置、旧密码和新密码(可以将其留空以表示没有密码).

This will then prompt you to enter the keyfile location, the old passphrase, and the new passphrase (which can be left blank to have no passphrase).

如果您想在没有提示的情况下在一行上完成所有操作,请执行以下操作:

If you would like to do it all on one line without prompts do:

$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]

重要提示: 请注意,在执行命令时,它们通常会以纯文本形式记录在您的 ~/.bash_history 文件(或类似文件)中,包括提供的所有参数(即在这种情况下的密码).因此,建议您使用第一个选项,除非您有特殊的理由不这样做.

Important: Beware that when executing commands they will typically be logged in your ~/.bash_history file (or similar) in plain text including all arguments provided (i.e. the passphrases in this case). It is, therefore, is recommended that you use the first option unless you have a specific reason to do otherwise.

请注意,您仍然可以使用 -f keyfile 而无需指定 -P-N,并且密钥文件默认为~/.ssh/id_rsa,所以在很多情况下,甚至不需要.

Notice though that you can still use -f keyfile without having to specify -P nor -N, and that the keyfile defaults to ~/.ssh/id_rsa, so in many cases, it's not even needed.

您可能需要考虑使用 ssh-agent,它可以将密码短语缓存一段时间.最新版本的 gpg-agent 也支持 ssh-agent 使用的协议.

You might want to consider using ssh-agent, which can cache the passphrase for a time. The latest versions of gpg-agent also support the protocol that is used by ssh-agent.

这篇关于如何在无需创建新密钥的情况下删除 SSH 密钥的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆