<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          How to specify a private key file in SSH 您所在的位置:網(wǎng)站首頁 屬雞打麻將的吉兇查詢 How to specify a private key file in SSH

          How to specify a private key file in SSH

          2025-07-16 10:45| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          How to specify a private key file in SSH

          Last updated on August 22, 2020 by Dan Nanni

          If you connect to a remote server via SSH, which only accepts key authentication, you need to present your private key to the SSH server for authentication. It is straightforward to do so by using SSH's command line option. But what if you have many different servers, each of which happens to require different private keys? It will be nice for you to be able to automatically load a certain private key with a specific SSH server. In the following, I describe how to do it.

          To specify a private key file in SSH from the command line, you can simply use -i option in the ssh command.

          Assume that you want to access ec2-23-22-230-24.compute-1.amazonaws.com with a private key located in ~/.ssh/alice.pem:

          $ ssh -i ~/.ssh/alice.pem [email?protected]

          However, things get complicated when you have multiple private keys. In that case, you can declare which private key to use for each SSH server, in your SSH configuration file which is found at ~/.ssh/config.

          $ vi ~/.ssh/config Host ec2-23-22-230-24.compute-1.amazonaws.com IdentityFile ~/.ssh/alice.pem Host ec2-33-01-200-71.compute-1.amazonaws.com IdentityFile ~/.ssh/alice_v2.pem . . .

          Then you can SSH without explicitly specifying your private key with -i option.

          $ ssh [email?protected]

          Note that the hostname (e.g., ec2-23-22-230-24.compute-1.amazonaws.com) specified with ssh command must match with that declared in .ssh/config. Thus even with the above .ssh/config, you cannot directly SSH to alternative names (e.g., IP address or hostname alias defined in /etc/hosts) of the SSH server, unless you also add them explicitly to ~/.ssh/config.

          Suppose 23.22.230.24 is the IP address of ec2-23-22-230-24.compute-1.amazonaws.com, and "my_ec2_host 23.22.230.24" is added in /etc/hosts. Then these alternative names must be declared in ~/.ssh/config as well in order you to use these names to connect to via SSH.

          Host ec2-23-22-230-24.compute-1.amazonaws.com IdentityFile ~/.ssh/alice.pem Host 23.22.230.24 IdentityFile ~/.ssh/alice.pem Host my_ec2_host IdentityFile ~/.ssh/alice.pem

          Then, all the following will work.

          $ ssh [email?protected] $ ssh [email?protected] $ ssh alice@my_ec2_host

          Support Xmodulo

          This website is made possible by minimal ads and your gracious donation via PayPal or credit card

          Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

          Xmodulo ? 2021 ? About ? Write for Us ? Feed ? Powered by DigitalOcean



          【本文地址】

          公司簡介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實驗室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 博乐市| 泾阳县| 缙云县| 册亨县| 丁青县| 英德市| 深州市| 无为县| 石嘴山市| 栖霞市| 凭祥市| 镇雄县| 中西区| 翼城县| 安新县| 阿克| 三原县| 永顺县| 无为县| 黄龙县| 南雄市| 景谷| 华坪县| 如皋市| 正蓝旗| 景德镇市| 安国市| 武威市| 蓬溪县| 安徽省| 清新县| 丘北县| 兴城市| 稻城县| 阳原县| 宣武区| 凤凰县| 上蔡县| 习水县| 岐山县| 甘洛县| http://444 http://444 http://444 http://444 http://444 http://444