{"id":184,"date":"2009-04-29T11:51:05","date_gmt":"2009-04-29T09:51:05","guid":{"rendered":"http:\/\/raftaman.net\/?p=184"},"modified":"2021-05-15T11:46:42","modified_gmt":"2021-05-15T09:46:42","slug":"using-ssh-keygen-ssh-copy-id","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=184","title":{"rendered":"Using ssh-keygen &#038; ssh-copy-id"},"content":{"rendered":"<p>Just because I always forget:<\/p>\n<h2> Step 1: Create public and private keys using ssh-keygen <\/h2>\n<pre class=\"brush: plain; highlight: [1]; light: true; title: ; notranslate\" title=\"\">\r\n&#x5B;user@Host ~]$ ssh-keygen\r\nGenerating public\/private rsa key pair.\r\nEnter file in which to save the key (\/home\/user\/.ssh\/id_rsa): \r\nCreated directory '\/home\/user\/.ssh'.\r\nEnter passphrase (empty for no passphrase): \r\nEnter same passphrase again: \r\nYour identification has been saved in \/home\/user\/.ssh\/id_rsa.\r\nYour public key has been saved in \/home\/user\/.ssh\/id_rsa.pub.\r\nThe key fingerprint is:\r\n0d:d2:94:07:93:a9:48:b9:33:73:fb:f1:6e:33:ce:d7 user@Host\r\nThe key's randomart image is:\r\n+--&#x5B; RSA 2048]----+\r\n|     .  +=       |\r\n|    o  o+..      |\r\n|   . o..o.       |\r\n|    * o. o       |\r\n|     = .S .      |\r\n|      . .        |\r\n|       . o   .   |\r\n|        ..= . E  |\r\n|         +++     |\r\n+-----------------+\r\n<\/pre>\n<h2> Step 2: Copy the public key to remote-host using ssh-copy-id <\/h2>\n<p>Now here comes the awesome part: You don&#8217;t have to scp the public key to your remote host and cat it into <code>~\/.ssh\/authorized_keys<\/code>. Instead, you can use ssh-copy-id<\/p>\n<pre class=\"brush: plain; highlight: [1]; light: true; title: ; notranslate\" title=\"\">\r\n&#x5B;user@Host ~]$ ssh-copy-id -i .ssh\/id_rsa.pub user@remote-host\r\nuser@remote-host's password: \r\nNow try logging into the machine, with &quot;ssh 'user@remote-host'&quot;, and check in:\r\n\r\n  .ssh\/authorized_keys\r\n\r\nto make sure we haven't added extra keys that you weren't expecting.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just because I always forget: Step 1: Create public and private keys using ssh-keygen &#x5B;user@Host ~]$ ssh-keygen Generating public\/private rsa key pair. Enter file in which to save the key (\/home\/user\/.ssh\/id_rsa): Created directory &#8216;\/home\/user\/.ssh&#8217;. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in \/home\/user\/.ssh\/id_rsa. Your public key has been saved in \/home\/user\/.ssh\/id_rsa.pub. The&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=184\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[28,15],"class_list":["post-184","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bash","tag-ssh"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":15,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":1141,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/1141"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}