{"id":1285,"date":"2019-09-11T15:35:51","date_gmt":"2019-09-11T22:35:51","guid":{"rendered":"https:\/\/portal.staylinked.com\/sl\/kb\/?post_type=ht_kb&#038;p=1285"},"modified":"2023-08-28T22:44:15","modified_gmt":"2023-08-29T05:44:15","slug":"keystore-file","status":"publish","type":"ht_kb","link":"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/","title":{"rendered":"SSH Public-Private Key Authentication"},"content":{"rendered":"\n<p>This article discusses the creation of a Private key (typically id_rsa) in a JKS keystore for Public-Private Key Authentication.  Think of Public-Private Key Authentication like a lock (the Public key on the Telnet Host) and a key for that lock (the Private key used by the telnet client).  When you connect with StayLinked using a Private key in a JKS keystore to a Telnet server with a User ID that has the matching Public key in its \"authorized_keys\" file (located in \/root\/.ssh for the root user),  it will let the user in without a password.<\/p>\n\n\n\n<p>Once you create the .jks file, it needs to be placed in the ..\\Stay-Linked folder.  It's also very important to set the specific Emulation Properties described below otherwise it will not work.&nbsp; <\/p>\n\n\n\n<p>Below we describe how to create the JKS Keystore on Linux.  Please note the following parameters:<\/p>\n\n\n\n<ul><li>The following steps were done with Java 8 on CentOS 8 and RHEL 7.6 with the root user profile, using PuTTY to enter the commands.<\/li><li>For Steps 2, 3, and 4 to work, it is necessary to change directory to the location of the id_rsa file.  This often is the ..\/.ssh directory provided in the ssh-keygen command.  For Linux logged on as Root this would be \/root\/.ssh<\/li><li>This procedure has also been confirmed to work on Windows 11 to connect to CentOS 8 and RHEL 7.6 using OpenSSH_for_Windows_8.6p1 (Step 1 with a path of \"%SYSTEMROOT%\\System32\\OpenSSH\\\"), and Win64 OpenSSL v3.1.2 (Step 2 and 3 with a path of \"C:\\Program Files\\OpenSSL-Win64\\bin\"), and Java 8 build (Step 4 with a path of \"C:\\Program Files\\Semeru\\jre-8.0.362.9-openj9\\bin\") to generate the files.  Please let StayLinked Support know if you need any additional assistance.<\/li><\/ul>\n\n\n<p><strong>Manual Creation of JKS KeyStore File<\/strong><br><!--StartFragment--><\/p>\n\n\n<p><strong>Step 1:<\/strong> Use OpenSSH to generate a PEM formatted Public-Private key pair.  The following command will generate a 2048-bit RSA Public-Private key pair.&nbsp; You can reduce this to 1024, but we suggest not going any lower.&nbsp; When this command is run, it will ask you to provide an optional passphrase (slpass will be used in our example). <\/p>\n\n\n\n<p>NOTE: If a private key is already provided, this step will be skipped.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <code>ssh-keygen -m PEM -t rsa -b 2048<\/code><\/p>\n\n\n\n<p>NOTE: If a PuTTY ppk file is provided, you can extract the id_rsa from it by following the instructions at the end of the KB article.<\/p>\n\n\n\n<p>NOTE: If you rename the generated id_rsa.pub to authorized_keys that will set the Public key for the ..\/.ssh folder where authorized_keys resides.<\/p>\n\n\n\n<p><strong>Step 2:<\/strong> Use OpenSSL to create a PEM certificate from the Private id_rsa key previously generated.  If you are provided a private key other than id_rsa, replace the 'id_rsa' in the following command with the name of the provided key.  This step will require the passphrase, if any, for the Private key (slpass in our example).  <\/p>\n\n\n\n<p>NOTE: The commands for steps 2 and 3 need to be run in the folder with the id_rsa file.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code> openssl req -new -x509 -key id_rsa -out cert.pem -days 365<\/code><\/p>\n\n\n\n<p>NOTE: The command will ask for misc. details to go in the PEM cert (these are functionally not important, so Enter can be pressed multiple times).<\/p>\n\n\n\n<p><strong>Step 3:<\/strong> Use OpenSSL to create an encrypted PKCS12 keystore from the Private key and PEM cert.  If you are provided the private key, replace the 'id_rsa' with the name of the provided key. <\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code> openssl pkcs12 -inkey id_rsa -in cert.pem -export -out ks.p12<\/code><\/p>\n\n\n\n<p>NOTE: If the id_rsa key has a password from step 1 and 2, you will be required to put in the passphrase for the Private key (slpass in our example).<\/p>\n\n\n\n<p>NOTE: You MUST provide a password for the exported PKCS #12 keystore to be used in Step 6 (exppass used in this example).<\/p>\n\n\n\n<p>NOTE: When the PKCS #12 is created, the Private key and PEM cert get added as a Personal Certificate with an Alias of '1'<\/p>\n\n\n\n<p><strong>Step 4:<\/strong> Use java to migrate the PKCS12 keystore to a JKS keystore.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code> keytool -importkeystore -srckeystore ks.p12 -destkeystore keystore.jks<\/code><\/p>\n\n\n\n<p>NOTE: You MUST provide a password for the exported JKS keystore to be used in Step 6 (jkspass used in this example).<\/p>\n\n\n\n<p><strong>Step 5: <\/strong>Remove the keystore.jks from the machine that generated it and place it in the root of the StayLinked server folder (..\/stay-linked).<\/p>\n\n\n\n<p><strong>Step 6: <\/strong>In the Administrator, add the following Emulation Properties along with standard SSH properties.&nbsp; These can be found under Emulation Settings -&gt; Telnet Host Groups -&gt; Telnet Host -&gt; Host Entry -&gt; Emulation Properties<\/p>\n\n\n\n<ul><li>SSH Public Key Alias (the value is \"1\" as described above)<\/li><li>SSH Public Key Alias Password (Alias password is set in the 3rd step&#8230; \"exppass\" in our example <strong>NOTE: JKS files created with Java versions other than 8 may require the Keystore Password from the 4th step instead<\/strong>) <\/li><li>SSH Public Keystore File Path (\"keystore.jks\" in our example)<\/li><li>SSH Public Keystore Password (Keystore password is set in the 4th step&#8230; \"jkspass\" in our example)<\/li><li>Use SSH Public Key Authentication (Set to \"True\"), not needed for VT-SMARTTE<\/li><\/ul>\n\n\n\n<p>NOTE: The file names and passwords do not have to match the example above and will depend on what was done in Step 3 and 4.<\/p>\n\n\n<p><strong>Exporting the Private key from a ppk file<\/strong><\/p>\n<p>This can be done fairly simply using PuTTYgen (PuTTY Key Generator).<\/p>\n<p>In the interface click on \"load\" and load the ppk (PuTTY Private Key) file.<\/p>\n<p>Once it is loaded, click on \"Conversions\" on the top, and \"Export OpenSSH key\".&nbsp; A Private key file that can be used in Step 2 of the above process, <strong>Manual Creation of JKS KeyStore File<\/strong>, will be created.&nbsp; NOTE: Do not use \"Export OpenSSH key (force new file format)\", it will not import using the command in Step 2.<\/p>","protected":false},"excerpt":{"rendered":"<p>This article discusses the creation of a Private key (typically id_rsa) in a JKS keystore for Public-Private Key Authentication. Think of Public-Private Key Authentication like a lock (the Public key on the Telnet Host) and a key for that lock (the Private key used by the telnet client). When you&#8230;<\/p>\n","protected":false},"author":7,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[25],"ht-kb-tag":[89,88,87,86],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SSH Public-Private Key Authentication &ndash; StayLinked<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.staylinked.com\/knowledge-base\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SSH Public-Private Key Authentication &ndash; StayLinked\" \/>\n<meta property=\"og:description\" content=\"This article discusses the creation of a Private key (typically id_rsa) in a JKS keystore for Public-Private Key Authentication. Think of Public-Private Key Authentication like a lock (the Public key on the Telnet Host) and a key for that lock (the Private key used by the telnet client). When you...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/\" \/>\n<meta property=\"og:site_name\" content=\"StayLinked\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-29T05:44:15+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/portal.staylinked.com\/sl\/kb\/#website\",\"url\":\"https:\/\/portal.staylinked.com\/sl\/kb\/\",\"name\":\"StayLinked Knowledge Base\",\"description\":\"Partner Portal Resources and Support\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/portal.staylinked.com\/sl\/kb\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/#webpage\",\"url\":\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/\",\"name\":\"SSH Public-Private Key Authentication &ndash; StayLinked\",\"isPartOf\":{\"@id\":\"https:\/\/portal.staylinked.com\/sl\/kb\/#website\"},\"datePublished\":\"2019-09-11T22:35:51+00:00\",\"dateModified\":\"2023-08-29T05:44:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/keystore-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/portal.staylinked.com\/sl\/kb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\/\/portal.staylinked.com\/sl\/kb\/knowledge-base\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SSH Public-Private Key Authentication\"}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb\/1285"}],"collection":[{"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/comments?post=1285"}],"version-history":[{"count":57,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb\/1285\/revisions"}],"predecessor-version":[{"id":4566,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb\/1285\/revisions\/4566"}],"wp:attachment":[{"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/media?parent=1285"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=1285"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/portal.staylinked.com\/sl\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=1285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}