AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 50775
Accepted
kch
kch
Asked: 2009-08-06 21:37:57 +0800 CST2009-08-06 21:37:57 +0800 CST 2009-08-06 21:37:57 +0800 CST

如何更改我的私钥密码?

  • 772

我有一个现有的公钥/私钥对。私钥受密码保护,加密可以是 RSA 或 DSA。这些密钥是您生成的类型ssh-keygen,通常存储在~/.ssh.

我想更改私钥的密码。在标准的 Unix shell 上,我该怎么做?

另外,我如何简单地删除密码?直接改成空的?

unix ssh ssh-keygen passphrase
  • 3 3 个回答
  • 310239 Views

3 个回答

  • Voted
  1. Best Answer
    Mike Mazur
    2009-08-06T22:01:05+08:002009-08-06T22:01:05+08:00

    要更改默认密钥上的密码:

    $ ssh-keygen -p
    

    如果需要指定密钥,请传递-f选项:

    $ ssh-keygen -p -f ~/.ssh/id_dsa
    

    然后在提示处提供您的旧密码和新密码(两次)。(~/.ssh/id_rsa如果您有 RSA 密钥,请使用。)

    更多详情来自man ssh-keygen:

    [...]
    SYNOPSIS
        ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment]
                   [-f output_keyfile]
        ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
    [...]
         -f filename
                 Specifies the filename of the key file.
    [...]
         -N new_passphrase
                 Provides the new passphrase.
    
         -P passphrase
                 Provides the (old) passphrase.
    
         -p      Requests changing the passphrase of a private key file instead of
                 creating a new private key.  The program will prompt for the file
                 containing the private key, for the old passphrase, and twice for
                 the new passphrase.
    [...]
    
    • 531
  2. mivk
    2020-11-20T06:54:13+08:002020-11-20T06:54:13+08:00

    如果没有ssh-keygen安装,也可以openssl直接使用

    key="/path/to/your.key"
    algo="-des3" # or -aes256 or ...
    
    openssl rsa $algo -in "$key" -out "$key.new"
    
    # and replace old key with new one
    mv "$key.new" "$key"
    
    • 2
  3. gauta
    2018-02-21T07:17:56+08:002018-02-21T07:17:56+08:00

    删除您的 SSH 公钥/私钥:

    rm ~/.ssh/id_rsa*
    

    重新创建密钥对,选择一个新的密码:

    ssh-keygen -t rsa -f ~/.ssh/id_rsa
    

    将新创建的私钥添加到您的 OS X 钥匙串以存储密码并自动管理解锁:

    ssh-add -K ~/.ssh/id_rsa
    

    将公钥复制到 OS X 剪贴板,以添加到 GitHub 等 Web 服务。

    cat ~/.ssh/id_rsa.pub | pbcopy
    

    将新创建的公钥添加到~/.ssh/authorized_keys远程服务器的文件中。请务必确保远程~/.ssh文件夹 (700) 和~/.ssh/authorized_keys(600) 的权限正确。您可能需要调查使用ssh-copy-id以简化此过程。

    • -14

相关问题

  • Windows SSH 客户端

  • 在 Windows Server 2003 上通过 SSH 启动和停止 Mongrel 服务

  • 隧道 Xbox 网络流量 [关闭]

  • 为什么使用authorized_keys通过ssh自动登录不起作用?

  • 更改 PHP 的默认配置设置?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve