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 / 问题 / 394555
Accepted
imaginative
imaginative
Asked: 2012-06-01 14:54:51 +0800 CST2012-06-01 14:54:51 +0800 CST 2012-06-01 14:54:51 +0800 CST

将私钥添加到 ssh 链

  • 772

我有多个用于连接各种盒子的私钥。这主要是针对 AWS,它让我导入一个密钥以便连接到机器——我为此创建了一个单独的密钥集。而不是不断地做:

ssh -i ~/.ssh/aws-key.pem [email protected]

添加aws-key.pem到我的“ssh keychain”的最佳方法是什么,以便它默认检查所有 SSH 请求以及现有的“id_dsa”密钥?

linux ssh
  • 2 2 个回答
  • 1403 Views

2 个回答

  • Voted
  1. Best Answer
    Zoredache
    2012-06-01T15:12:45+08:002012-06-01T15:12:45+08:00

    你有几个选择。

    使用SSH 代理。只需对所有私钥使用 ssh-add,然后让您的代理确定要使用的密钥。我通常更喜欢使用代理,并且总是在我登录到我的系统时启动它,并添加我所有的密钥。它让一切变得简单。

    更改您的 ssh 配置

    # .ssh/config
    
    # per host example
    Host blah.example.com
        User zoredache
        IdentityFile ~/.ssh/username_YYYYMMDD_id_rsa
    
    # global example
    Host *
        User zoredache
        IdentityFile ~/.ssh/key1_YYYYMMDD_id_rsa
        IdentityFile ~/.ssh/key2_YYYYMMDD_id_rsa
        IdentityFile ~/.ssh/keyn_YYYYMMDD_id_rsa
    
    • 8
  2. 84104
    2012-06-01T14:59:41+08:002012-06-01T14:59:41+08:00

    使用IdentityFile于~/.ssh/config

    如果您只想为特定主机使用它,请将其包含在Host指令下。

         IdentityFile
             Specifies a file from which the user's DSA, ECDSA or DSA authentication identity is read.  The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa,
             ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2.  Additionally, any identities represented by the authentication agent will be used for authentication.  ssh(1) will
             try to load certificate information from the filename obtained by appending -cert.pub to the path of a specified IdentityFile.
    
             The file name may use the tilde syntax to refer to a user's home directory or one of the following escape characters: ‘%d’ (local user's home directory), ‘%u’ (local user
             name), ‘%l’ (local host name), ‘%h’ (remote host name) or ‘%r’ (remote user name).
    
             It is possible to have multiple identity files specified in configuration files; all these identities will be tried in sequence.  Multiple IdentityFile directives will add
             to the list of identities tried (this behaviour differs from that of other configuration directives).
    
    • 5

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

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

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

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

    • 9 个回答
  • Marko Smith

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

    • 3 个回答
  • Marko Smith

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

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +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