0554.html 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Configure SSH Key-Based Authentication on a Linux</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Home Lab,Home Lab Ideas,Home Networking,Ubuntu,SSH,Public Key Infrastructure,PKI,Linux,Authentication,Administration,Certificates,Debian,Secure Shell,How To Setup Linux Key Based Authentication,Key Based Authentication,Key-Based Authentication,SSH Key-Based Authentication,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Configure SSH Key-Based Authentication on a Linux">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="05/20/2022 03:10:48 PM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Configure SSH Key-Based Authentication on a Linux</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>Connecting from a Linux Host</h2>
  26. <ol>
  27. <li>Log into the source Linux host</li>
  28. <li>Run the following command in a terminal window
  29. <div class="codeBlock"># generate a new ssh key pair<br />
  30. ssh-keygen -t rsa</div>
  31. </li>
  32. <li>Press enter to accept the default location</li>
  33. <li>Optionally, set a password for the key pair<br />
  34. <em>NOTE: If you don&#39;t provide a password, anyone with the key and access to the target host can connect using the key. Proceed with caution</em></li>
  35. <li>Continue with the following command
  36. <div class="codeBlock"># output the public key<br />
  37. cat ~/.ssh/id_rsa.pub</div>
  38. </li>
  39. <li>Copy the output ssh-rsa public key to the clipboard</li>
  40. <li>Log into the target Linux machine</li>
  41. <li>Run the following command in a terminal window
  42. <div class="codeBlock"># create .ssh directory<br />
  43. mkdir ~/.ssh -p<br />
  44. # edit the authorized_keys file<br />
  45. nano ~/.ssh/authorized_keys</div>
  46. </li>
  47. <li>Paste the copied public key to the bottom of the file</li>
  48. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  49. <li>Back on the source Linux device, connect to the Linux target using ssh (ie ssh username@hostname)</li>
  50. <li>Type yes and press Enter the first time connecting with a new public key to accept the connection</li>
  51. </ol>
  52. <h2>Connecting from a Windows Host</h2>
  53. <ol>
  54. <li>Log into the Windows host</li>
  55. <li>Right click the Start menu &gt; Run &gt; Type cmd &gt; Press Enter</li>
  56. <li>Run the following command in the command prompt
  57. <div class="codeBlock CMD"># generate a new ssh key pair<br />
  58. ssh-keygen -t rsa</div>
  59. </li>
  60. <li>Press enter to accept the default location</li>
  61. <li>Optionally, set a password for the key pair<br />
  62. <em>NOTE: If you don&#39;t provide a password, anyone with the public key and access to the target host can connect using the key</em></li>
  63. <li>Continue with the following command
  64. <div class="codeBlock CMD"># output the public key<br />
  65. type %userprofile%\.ssh\id_rsa.pub</div>
  66. </li>
  67. <li>Copy the output ssh-rsa public key to the clipboard</li>
  68. <li>Log into the target Linux machine</li>
  69. <li>Run the following command in a terminal window
  70. <div class="codeBlock CMD"># create .ssh directory<br />
  71. mkdir ~/.ssh -p<br />
  72. # edit the authorized_keys file<br />
  73. nano ~/.ssh/authorized_keys</div>
  74. </li>
  75. <li>Paste the copied public key to the bottom of the file</li>
  76. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  77. <li>Back on the Windows device, connect to the Linux target using ssh (ie ssh username@hostname)</li>
  78. <li>Type yes and press Enter the first time connecting with a new public key to accept the connection</li>
  79. </ol> </div>
  80. </div>
  81. </body>
  82. </html>