{"id":1222,"date":"2023-11-28T14:31:13","date_gmt":"2023-11-28T19:31:13","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=1222"},"modified":"2023-11-29T16:20:21","modified_gmt":"2023-11-29T21:20:21","slug":"how-to-generate-public-private-keys","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/how-to-generate-public-private-keys\/","title":{"rendered":"How to generate public\/private keys"},"content":{"rendered":"\n<p>This post shows how to generate public \/ private key pair.<\/p>\n\n\n\n<p><strong>To generate public\/private key pair, simply run the following command:<br>$ ssh-keygen -t rsa<\/strong><\/p>\n\n\n\n<p>Following are step-by-step instructions:<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>Open your terminal window in your Linux, Mac, or Windows machine by typing terminal in the search box or spotlight.<\/p>\n\n\n\n<p><strong>2.\u00a0<\/strong>Type the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-key -t rsa<\/code><\/pre>\n\n\n\n<p><strong>3.\u00a0<\/strong>You should see a prompt like the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Generating public\/private rsa key pair. \nEnter file in which to save the key (C:\\Users\\myuser\/.ssh\/id_rsa):<\/pre>\n\n\n\n<p><strong>4.\u00a0<\/strong>Press the return key and it will create a .ssh directory as below. Alternately you can define a different location for the key pair.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Created directory 'C:\\Users\\myuser\/.ssh'. \nEnter passphrase (empty for no passphrase):<\/code><\/pre>\n\n\n\n<p><strong>5.\u00a0<\/strong>You will be prompted to type a password twice. The you will get confirmation of the creation of your keys:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Your identification has been saved in C:\\Users\\myuser\/.ssh\/id_rsa. Your public key has been saved in C:\\Users\\myuser\/.ssh\/id_rsa.pub. \nThe key fingerprint is:\nSHA256:gITKSpgtUIyyV14qKrFjFSSQvSFW6vylQGappLeWDmE \nsomesystem\\someuser@deviceid \nThe key's randomart image is: \n+---[RSA 2048]----+ \n|.oo+=+o. | \n|= ..o=* . . | \n|==..S=.* o . | \n|==oB. B.. S | \n|=Eo.+. oS | \n|oo E o o | \n|. + o | \n| + | \n| . | \n+----[SHA256]-----+<\/pre>\n\n\n\n<p>Note that the private key is id_rsa. This is the key you should never share. id_rsa.pub is the public key. You share this key. Any data encrypted with your public key can only be opened with your private key.<\/p>\n\n\n\n<p><strong>Copying your key pair to a server<\/strong><\/p>\n\n\n\n<p>To copy your key to a server, user secure copy (scp) as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scp ~\/.ssh\/id_rsa.pub xyz.com:~\/.ssh\/authorized_keys<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post shows how to generate public \/ private key pair. To generate public\/private key pair, simply run the following command:$ ssh-keygen -t rsa Following are step-by-step instructions: 1.&nbsp;Open your terminal window in your Linux, Mac, or Windows machine by typing terminal in the search box or spotlight. 2.\u00a0Type the following command 3.\u00a0You should see [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1223,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,34],"tags":[378,380,379],"class_list":["post-1222","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","category-linux","tag-cryptography-basics","tag-key-pair-generation","tag-public-key-encryption"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=1222"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1222\/revisions"}],"predecessor-version":[{"id":1224,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1222\/revisions\/1224"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/1223"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=1222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=1222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=1222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}