forked from docs/doc-exports
Reviewed-by: Pristromskaia, Margarita <margarita.pristromskaia@t-systems.com> Co-authored-by: wanghuijuan738 <wanghuijuan738@huawei.com> Co-committed-by: wanghuijuan738 <wanghuijuan738@huawei.com>
59 lines
17 KiB
HTML
59 lines
17 KiB
HTML
<a name="EN-US_TOPIC_0017955380"></a><a name="EN-US_TOPIC_0017955380"></a>
|
|
|
|
<h1 class="topictitle1">Logging In to a Linux ECS Using an SSH Key Pair</h1>
|
|
<div id="body1437210781593"><div class="section" id="EN-US_TOPIC_0017955380__section1547194115913"><h4 class="sectiontitle">Scenarios</h4><p id="EN-US_TOPIC_0017955380__p02511214133315">Key pairs (SSH key pairs) are a set of security credentials for identity authentication when you remotely log in to ECSs.</p>
|
|
<p id="EN-US_TOPIC_0017955380__p2036485114357">A key pair consists of a public key and a private key. Key Pair Service (KPS) stores the public key and you store the private key. If you have bound a public key to a Linux ECS, you can use the corresponding private key, rather than a password, to log in to the ECS. You do not need to worry about password interception, cracking, or leakage.</p>
|
|
<p id="EN-US_TOPIC_0017955380__p11171251369">For details, see <a href="en-us_topic_0000001278335673.html">Application Scenarios for Using Key Pairs</a>.</p>
|
|
<p id="EN-US_TOPIC_0017955380__p112185456913">This section describes how to use an SSH key pair to remotely log in to a Linux ECS from a Windows and a Linux server, respectively.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0017955380__section6801971111724"><h4 class="sectiontitle">Prerequisites</h4><ul id="EN-US_TOPIC_0017955380__ul14088797111724"><li id="EN-US_TOPIC_0017955380__li839131523818">The <span id="EN-US_TOPIC_0017955380__text050215168713">ECS</span> status must be <strong id="EN-US_TOPIC_0017955380__b0503316176">Running</strong>.</li><li id="EN-US_TOPIC_0017955380__li8057630204858">You have obtained the private key file (.pem) generated during the <span id="EN-US_TOPIC_0017955380__text1710831620141">ECS</span> creation. For details about how to create a key pair, see <a href="en-us_topic_0000001278350057.html">(Recommended) Creating a Key Pair on the Management Console</a>.</li><li id="EN-US_TOPIC_0017955380__li59690312111724">You have bound an <span id="EN-US_TOPIC_0017955380__text19427938133910">EIP</span> to the <span id="EN-US_TOPIC_0017955380__text16427138103917">ECS</span>. For details, see <a href="en-us_topic_0017130261.html">Viewing ECS Details</a>.</li></ul>
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0017955380__ul341899111724"><li id="EN-US_TOPIC_0017955380__li3077095111724">You have configured the inbound rules of the security group. For details, see <a href="en-us_topic_0030878383.html">Configuring Security Group Rules</a>.</li><li id="EN-US_TOPIC_0017955380__li23377058164348">The network connection between the login tool (PuTTY) and the target <span id="EN-US_TOPIC_0017955380__text912922101412">ECS</span> is normal. For example, the default port 22 is not blocked by the firewall.</li></ul>
|
|
<div class="section" id="EN-US_TOPIC_0017955380__section47918167111724"><a name="EN-US_TOPIC_0017955380__section47918167111724"></a><a name="section47918167111724"></a><h4 class="sectiontitle">Logging In to a Linux ECS from a Local Windows Server</h4><p id="EN-US_TOPIC_0017955380__p56166336111724">You have two methods to log in to a Linux <span id="EN-US_TOPIC_0017955380__text9196132313143">ECS</span> from a local Windows server.</p>
|
|
<p id="EN-US_TOPIC_0017955380__p49673096204924"><strong id="EN-US_TOPIC_0017955380__b842352706101120">Method 1: Use PuTTY to log in to the ECS.</strong></p>
|
|
<div class="p" id="EN-US_TOPIC_0017955380__p3507989320731">The following operations use PuTTY as an example. Before using PuTTY to log in, make sure that the private key file has been converted to .ppk format.<ol id="EN-US_TOPIC_0017955380__ol53179337111724"><li id="EN-US_TOPIC_0017955380__li5774252720735">Check whether the private key file has been converted to .ppk format.<ul id="EN-US_TOPIC_0017955380__ul3906000820958"><li id="EN-US_TOPIC_0017955380__li1599575920958">If yes, go to step <a href="#EN-US_TOPIC_0017955380__li40879966111724">7</a>.</li><li id="EN-US_TOPIC_0017955380__li5850240020107">If no, go to step <a href="#EN-US_TOPIC_0017955380__li8851985111724">2</a>.</li></ul>
|
|
</li><li id="EN-US_TOPIC_0017955380__li8851985111724"><a name="EN-US_TOPIC_0017955380__li8851985111724"></a><a name="li8851985111724"></a>Visit the following website and download PuTTY and PuTTYgen:<p id="EN-US_TOPIC_0017955380__p12559002111724"><a name="EN-US_TOPIC_0017955380__li8851985111724"></a><a name="li8851985111724"></a><a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html" target="_blank" rel="noopener noreferrer">https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html</a></p>
|
|
<div class="note" id="EN-US_TOPIC_0017955380__note45922157111724"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0017955380__p10646236111724">PuTTYgen is a key generator, which is used to create a key pair that consists of a public key and a private key for PuTTY.</p>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li28707262111724">Run PuTTYgen.</li><li id="EN-US_TOPIC_0017955380__en-us_topic_0017955380_li57038774111724">In the <span class="uicontrol" id="EN-US_TOPIC_0017955380__uicontrol5606020615468"><b>Actions</b></span> pane, click <span class="uicontrol" id="EN-US_TOPIC_0017955380__uicontrol49150490154634"><b>Load</b></span> and import the private key file that you stored during <span id="EN-US_TOPIC_0017955380__text85971227101419">ECS</span> creation.<p id="EN-US_TOPIC_0017955380__p30529907154714">Ensure that the format of <span class="parmvalue" id="EN-US_TOPIC_0017955380__parmvalue155511305120301"><b>All files (*.*)</b></span> is selected.</p>
|
|
<div class="fignone" id="EN-US_TOPIC_0017955380__fig124131936512"><span class="figcap"><b>Figure 1 </b>Importing the private key file</span><br><span><img id="EN-US_TOPIC_0017955380__image12413239510" src="en-us_image_0000001744520501.png" title="Click to enlarge" class="imgResize"></span></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li43586924111724">In the <span class="uicontrol" id="EN-US_TOPIC_0017955380__uicontrol1560451631317"><b>Actions</b></span> area, click <strong id="EN-US_TOPIC_0017955380__b360722131314">Save private key</strong>.</li><li id="EN-US_TOPIC_0017955380__li56738001111724"><a name="EN-US_TOPIC_0017955380__li56738001111724"></a><a name="li56738001111724"></a>Save the converted private key, for example, <strong id="EN-US_TOPIC_0017955380__b2606737101317">kp-123.ppk</strong>, to the local computer.</li><li id="EN-US_TOPIC_0017955380__li40879966111724"><a name="EN-US_TOPIC_0017955380__li40879966111724"></a><a name="li40879966111724"></a>Double-click <strong id="EN-US_TOPIC_0017955380__b842352706195943">PUTTY.EXE</strong>. The <strong id="EN-US_TOPIC_0017955380__b842352706195959">PuTTY Configuration</strong> page is displayed.</li><li id="EN-US_TOPIC_0017955380__li706469820233">Choose <strong id="EN-US_TOPIC_0017955380__b06321172620">Session</strong> and enter the <span id="EN-US_TOPIC_0017955380__text1249381314488">EIP</span> of the <span id="EN-US_TOPIC_0017955380__text1364564614141">ECS</span> under <strong id="EN-US_TOPIC_0017955380__b85302261565">Host Name (or IP address)</strong>.<div class="fignone" id="EN-US_TOPIC_0017955380__fig3739272820239"><span class="figcap"><b>Figure 2 </b>Configuring the <span id="EN-US_TOPIC_0017955380__text18667151454813">EIP</span></span><br><span><img id="EN-US_TOPIC_0017955380__image4549210120228" src="en-us_image_0000001082643605.jpg" title="Click to enlarge" class="imgResize"></span></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li26002391163516">Choose <strong id="EN-US_TOPIC_0017955380__b842352706164122">Connection</strong> > <strong id="EN-US_TOPIC_0017955380__b842352706164125">Data</strong>. Enter the image username in <strong id="EN-US_TOPIC_0017955380__b842352706164253">Auto-login username</strong>.<div class="fignone" id="EN-US_TOPIC_0017955380__fig8436202814919"><span class="figcap"><b>Figure 3 </b>Entering the username</span><br><span><img id="EN-US_TOPIC_0017955380__image44378284911" src="en-us_image_0000001744562821.png" title="Click to enlarge" class="imgResize"></span></div>
|
|
<div class="note" id="EN-US_TOPIC_0017955380__note289224152455"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0017955380__ul20706144145520"><li id="EN-US_TOPIC_0017955380__li3706349551">If a public image is used, see <em id="EN-US_TOPIC_0017955380__i1266614172017"><a href="https://docs.otc.t-systems.com/image-management-service/public-images/" target="_blank" rel="noopener noreferrer">Image Management Service - Public Image Introduction</a></em> for the image username.</li><li id="EN-US_TOPIC_0017955380__li13706164145511">If a private image is used, use the username of the private image.</li></ul>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li22942973111724">Choose <strong id="EN-US_TOPIC_0017955380__b1761383791316">Connection</strong> > <strong id="EN-US_TOPIC_0017955380__b361318376135">SSH</strong> > <strong id="EN-US_TOPIC_0017955380__b86131237101318">Auth</strong> > <strong id="EN-US_TOPIC_0017955380__b586945018103">Credentials</strong>. In the configuration item <strong id="EN-US_TOPIC_0017955380__b1361373710133">Private key file for authentication</strong>, click <strong id="EN-US_TOPIC_0017955380__b06131837181320">Browse</strong> and select the private key converted in step <a href="#EN-US_TOPIC_0017955380__li56738001111724">6</a>.<div class="fignone" id="EN-US_TOPIC_0017955380__fig412203341117"><span class="figcap"><b>Figure 4 </b>Importing the private key file</span><br><span><img id="EN-US_TOPIC_0017955380__image2123133314117" src="en-us_image_0000001696804084.png" title="Click to enlarge" class="imgResize"></span></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li46441520111724">Click <strong id="EN-US_TOPIC_0017955380__b1761683712136">Open</strong> to log in to the <span id="EN-US_TOPIC_0017955380__text27241101274">ECS</span>.</li></ol>
|
|
</div>
|
|
<p id="EN-US_TOPIC_0017955380__p59947944205032"><strong id="EN-US_TOPIC_0017955380__b842352706102336">Method 2: Use Xshell to log in to the ECS.</strong></p>
|
|
<ol id="EN-US_TOPIC_0017955380__ol54723507205051"><li id="EN-US_TOPIC_0017955380__li58876908205051">Start the Xshell tool.</li><li id="EN-US_TOPIC_0017955380__li4831310620510">Run the following command using the <span id="EN-US_TOPIC_0017955380__text426816163483">EIP</span> to remotely log in to the <span id="EN-US_TOPIC_0017955380__text19680144951417">ECS</span> through SSH:<p id="EN-US_TOPIC_0017955380__p29511049205142"><strong id="EN-US_TOPIC_0017955380__b1329075119127">ssh</strong> <em id="EN-US_TOPIC_0017955380__i43747441164643"><strong id="EN-US_TOPIC_0017955380__b66820451164643">username</strong></em><strong id="EN-US_TOPIC_0017955380__b53881836164643">@<em id="EN-US_TOPIC_0017955380__i113013262529"><span id="EN-US_TOPIC_0017955380__text0607191575217">EIP</span></em></strong></p>
|
|
<div class="note" id="EN-US_TOPIC_0017955380__note833517545353"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0017955380__en-us_topic_0017955380_ul20706144145520"><li id="EN-US_TOPIC_0017955380__en-us_topic_0017955380_li3706349551">If a public image is used, see <em id="EN-US_TOPIC_0017955380__en-us_topic_0017955380_i1266614172017"><a href="https://docs.otc.t-systems.com/image-management-service/public-images/" target="_blank" rel="noopener noreferrer">Image Management Service - Public Image Introduction</a></em> for the image username.</li><li id="EN-US_TOPIC_0017955380__en-us_topic_0017955380_li13706164145511">If a private image is used, use the username of the private image.</li></ul>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li65527645205310">(Optional) If the system displays the <strong id="EN-US_TOPIC_0017955380__b842352706103315">SSH Security Warning</strong> dialog box, click <strong id="EN-US_TOPIC_0017955380__b842352706103435">Accept & Save</strong>.<div class="fignone" id="EN-US_TOPIC_0017955380__fig680319562495"><span class="figcap"><b>Figure 5 </b>SSH Security Warning</span><br><span><img id="EN-US_TOPIC_0017955380__image18772506254" src="en-us_image_0178475901.png"></span></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li56881900205338">Select <strong id="EN-US_TOPIC_0017955380__b842352706103545">Public Key</strong> and click <strong id="EN-US_TOPIC_0017955380__b84235270610371">Browse</strong> beside the user key text box.</li><li id="EN-US_TOPIC_0017955380__li10975823205436">In the user key dialog box, click <strong id="EN-US_TOPIC_0017955380__b842352706103758">Import</strong>.</li><li id="EN-US_TOPIC_0017955380__li612943622102">Select the locally stored key file and click <strong id="EN-US_TOPIC_0017955380__b842352706103847">Open</strong>.</li><li id="EN-US_TOPIC_0017955380__li26892298205533">Click <strong id="EN-US_TOPIC_0017955380__b1384755286">OK</strong> to log in to the <span id="EN-US_TOPIC_0017955380__text777655001419">ECS</span>.</li></ol>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0017955380__section3666784111724"><a name="EN-US_TOPIC_0017955380__section3666784111724"></a><a name="section3666784111724"></a><h4 class="sectiontitle">Logging In to a Linux ECS from a Local Linux Server</h4><div class="p" id="EN-US_TOPIC_0017955380__p28574068111724">To log in to the Linux <span id="EN-US_TOPIC_0017955380__text0729145251416">ECS</span> from local Linux, perform the operations described in this section. The following operations use private key file <strong id="EN-US_TOPIC_0017955380__b184804218611">kp-123.pem</strong> as an example to log in to the ECS. The name of your private key file may differ.<ol id="EN-US_TOPIC_0017955380__ol55840023111724"><li id="EN-US_TOPIC_0017955380__li32798165111724">On the Linux CLI, run the following command to change operation permissions:<p id="EN-US_TOPIC_0017955380__p26748029111724"><a name="EN-US_TOPIC_0017955380__li32798165111724"></a><a name="li32798165111724"></a><strong id="EN-US_TOPIC_0017955380__b141829542515418">chmod 400 /</strong><em id="EN-US_TOPIC_0017955380__i119870989715418">path</em><strong id="EN-US_TOPIC_0017955380__b182456313515424">/kp-123</strong><strong id="EN-US_TOPIC_0017955380__b1356401439193047">.pem</strong></p>
|
|
<div class="note" id="EN-US_TOPIC_0017955380__note19106747111724"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0017955380__p37743003111724">In the preceding command, replace <em id="EN-US_TOPIC_0017955380__i1681691002125432">path</em> with the actual path where the key file is saved.</p>
|
|
</div></div>
|
|
</li><li id="EN-US_TOPIC_0017955380__li4142714111724">Run the following command to log in to the <span id="EN-US_TOPIC_0017955380__text1087825831416">ECS</span>:<p id="EN-US_TOPIC_0017955380__p51016140103357"><strong id="EN-US_TOPIC_0017955380__b8935174191314">ssh -i /<em id="EN-US_TOPIC_0017955380__i393524161316">path</em>/kp-123.pem</strong> <em id="EN-US_TOPIC_0017955380__i17658378151627"><strong id="EN-US_TOPIC_0017955380__b46701284151627">Default username</strong></em><strong id="EN-US_TOPIC_0017955380__b7166428201240">@</strong><em id="EN-US_TOPIC_0017955380__i1779413984815"><strong id="EN-US_TOPIC_0017955380__b1951939114818"><span id="EN-US_TOPIC_0017955380__text14536992112">EIP</span></strong></em></p>
|
|
<p id="EN-US_TOPIC_0017955380__p34995982103441">For example, if the default username is <strong id="EN-US_TOPIC_0017955380__b65818104402">root</strong> and the <span id="EN-US_TOPIC_0017955380__text1674420044014">EIP</span> is <strong id="EN-US_TOPIC_0017955380__b16744608409">123.123.123.123</strong>, run the following command:</p>
|
|
<p id="EN-US_TOPIC_0017955380__p37284434111724"><strong id="EN-US_TOPIC_0017955380__b2680330715535">ssh -i /<em id="EN-US_TOPIC_0017955380__i15586111724">path</em>/kp-123.pem root@</strong><strong id="EN-US_TOPIC_0017955380__b1890475919385">123.123.123.123</strong></p>
|
|
<div class="note" id="EN-US_TOPIC_0017955380__note1262490111724"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0017955380__p5866139194411">In the preceding command:</p>
|
|
<ul id="EN-US_TOPIC_0017955380__ul11362411111724"><li id="EN-US_TOPIC_0017955380__li35152842111724"><em id="EN-US_TOPIC_0017955380__i05266161117">path</em> refers to the path under which the key file is stored.</li><li id="EN-US_TOPIC_0017955380__li47940127111724"><em id="EN-US_TOPIC_0017955380__i15286162081218">EIP</em> is the <span id="EN-US_TOPIC_0017955380__text28038290489">EIP</span> bound to the <span id="EN-US_TOPIC_0017955380__text1084392191516">ECS</span>.</li></ul>
|
|
</div></div>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0030831990.html">Logging In to a Linux ECS</a></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script language="JavaScript">
|
|
<!--
|
|
image_size('.imgResize');
|
|
var msg_imageMax = "view original image";
|
|
var msg_imageClose = "close";
|
|
//--></script> |