{"id":2217,"date":"2022-02-25T07:14:21","date_gmt":"2022-02-25T07:14:21","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=2217"},"modified":"2022-02-25T09:03:12","modified_gmt":"2022-02-25T09:03:12","slug":"ssh-keygen-ssh-copy-id","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2022\/02\/25\/ssh-keygen-ssh-copy-id\/","title":{"rendered":"ssh-keygen &#038; ssh-copy-id"},"content":{"rendered":"\n<p><code>ssh-keygen<\/code> allows generation of new key pair for authentication (SSH).<\/p>\n\n\n\n<pre class=\"wp-block-code has-luminous-vivid-amber-background-color has-background\"><code>&gt; ssh-keygen --help\nunknown option -- -\nusage: ssh-keygen &#91;-q] &#91;-b bits] &#91;-t dsa | ecdsa | ed25519 | rsa | rsa1]\n                  &#91;-N new_passphrase] &#91;-C comment] &#91;-f output_keyfile]\n       ssh-keygen -p &#91;-P old_passphrase] &#91;-N new_passphrase] &#91;-f keyfile]\n       ssh-keygen -i &#91;-m key_format] &#91;-f input_keyfile]\n       ssh-keygen -e &#91;-m key_format] &#91;-f input_keyfile]\n       ssh-keygen -y &#91;-f input_keyfile]\n       ssh-keygen -c &#91;-P passphrase] &#91;-C comment] &#91;-f keyfile]\n       ssh-keygen -l &#91;-v] &#91;-E fingerprint_hash] &#91;-f input_keyfile]\n       ssh-keygen -B &#91;-f input_keyfile]\n       ssh-keygen -D pkcs11\n       ssh-keygen -F hostname &#91;-f known_hosts_file] &#91;-l]\n       ssh-keygen -H &#91;-f known_hosts_file]\n       ssh-keygen -R hostname &#91;-f known_hosts_file]\n       ssh-keygen -r hostname &#91;-f input_keyfile] &#91;-g]\n       ssh-keygen -G output_file &#91;-v] &#91;-b bits] &#91;-M memory] &#91;-S start_point]\n       ssh-keygen -T output_file -f input_file &#91;-v] &#91;-a rounds] &#91;-J num_lines]\n                  &#91;-j start_line] &#91;-K checkpt] &#91;-W generator]\n       ssh-keygen -s ca_key -I certificate_identity &#91;-h] &#91;-n principals]\n                  &#91;-O option] &#91;-V validity_interval] &#91;-z serial_number] file ...\n       ssh-keygen -L &#91;-f input_keyfile]\n       ssh-keygen -A\n       ssh-keygen -k -f krl_file &#91;-u] &#91;-s ca_public] &#91;-z version_number]\n                  file ...\n       ssh-keygen -Q -f krl_file file ...<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-light-green-cyan-background-color has-background\"><code>ssh-keygen -t rsa\nGenerating public\/private rsa key pair.\nEnter file in which to save the key (\/root\/.ssh\/id_rsa): \nEnter passphrase (empty for no passphrase): \nEnter same passphrase again: \nYour identification has been saved in \/root\/.ssh\/id_rsa.\nYour public key has been saved in \/root\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\nSHA256:KjqBCXEEFIBOOPDJ6j45tOBogwggxw3pAqECLG\/r9fI root@mymachine.net\nThe key's randomart image is:\n+---&#91;RSA 2048]----+\n|%* .             |\n|%==.             |\n|O*+o             |\n|*o* .            |\n|=* .    S        |\n|*.o .  .         |\n|Oooo...          |\n|=Oo....          |\n|..=. oE          |\n+----&#91;SHA256]-----+<\/code><\/pre>\n\n\n\n<div class=\"wp-block-snow-monkey-blocks-alert smb-alert wp-block-snow-monkey-blocks-alert-is-layout-constrained\"><div class=\"smb-alert__title\"><i class=\"fas fa-exclamation-circle\"><\/i><strong><strong>SSH Keys<\/strong><\/strong><\/div><div class=\"smb-alert__body is-layout-constrained wp-block-alert-is-layout-constrained\"><p>&#8211; The&nbsp;SSH protocol&nbsp;uses public key cryptography for authenticating hosts and users. <strong><strong>&nbsp;<\/strong><\/strong><\/p><p>&#8211; SSH keys are authentication credentials just like passwords.&nbsp;<\/p><\/div><\/div>\n\n\n\n<p><code>ssh-copy-id<\/code> allows copying\/installation of public key to a server to allow public key authentication.<\/p>\n\n\n\n<pre class=\"wp-block-code has-luminous-vivid-amber-background-color has-background\"><code>&gt; ssh-copy-id -h\nUsage: \/usr\/bin\/ssh-copy-id &#91;-h|-?|-f|-n] &#91;-i &#91;identity_file]] &#91;-p port] &#91;&#91;-o &lt;ssh -o options&gt;] ...] &#91;user@]hostname\n        -f: force mode -- copy keys without trying to check if they are already installed\n        -n: dry run    -- no keys are actually copied\n        -h|-?: print this help<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-light-green-cyan-background-color has-background\"><code>> ssh-copy-id root@othermachine.net\n\/usr\/bin\/ssh-copy-id: INFO: Source of key(s) to be installed: \"\/root\/.ssh\/id_rsa.pub\"\n\/usr\/bin\/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n\/usr\/bin\/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys\nroot@othermachine.net's password: \n \nNumber of key(s) added: 1\n\nNow try logging into the machine, with:   \"ssh 'root@othermachine.net'\"\nand check to make sure that only the key(s) you wanted were added.<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ssh-keygen allows generation of new key pair for authentication (SSH). SSH Keys &#8211; The&nbsp;SSH protocol&nbsp;uses public key cryptography for authenticating hosts and users. &nbsp; &#8211; SSH keys are authentication credentials just like passwords.&nbsp; ssh-copy-id allows copying\/installation of public key to a server to allow public key authentication.<\/p>\n","protected":false},"author":1,"featured_media":1405,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[247],"class_list":["post-2217","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-technical","tag-ssh-key-gen","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=2217"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/2217\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/1405"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=2217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=2217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=2217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}