{"id":159,"date":"2023-08-06T10:15:19","date_gmt":"2023-08-06T10:15:19","guid":{"rendered":"https:\/\/techbanda.com\/blog\/?p=159"},"modified":"2023-10-20T04:45:06","modified_gmt":"2023-10-20T04:45:06","slug":"ssh-public-key-auth-for-remote-access","status":"publish","type":"post","link":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/","title":{"rendered":"Set up SSH Public Key Auth for Remote Access"},"content":{"rendered":"\n<p class=\"has-text-align-center\">How to Set up SSH Public Key Auth for Remote Access<\/p>\n\n\n\n<p class=\"has-text-align-left has-regular-font-size\">Secure Shell (SSH) is a widely-used cryptographic network protocol for securely connecting to remote servers and systems. While traditional password-based auth is still common, using SSH keys provides an additional layer of security and convenience. SSH public key auth relies on asymmetric cryptographic algorithms that generate a pair of separate keys (a key pair), one &#8220;private&#8221; and the other &#8220;public&#8221;. You keep the private key a secret and store it on the computer you use to connect to the remote system. In this blog, we&#8217;ll walk you through the process of generating an SSH key, copying the public key to a remote server, and connecting to it using SSH key auth. Let&#8217;s start .<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong><em>Step 1: Generating an SSH Key<\/em><\/strong><\/h5>\n\n\n\n<p>The first step is to generate an SSH key pair on your local machine. To do this, open a terminal or command prompt and execute the following command:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">ssh-keygen -t rsa<\/mark><\/strong><\/code><\/pre>\n\n\n\n<p>You&#8217;ll be prompted to choose a location to save the key pair. The default location is usually <code>`~\/.ssh\/id_rsa`<\/code> for the private key and <code>`~\/.ssh\/id_rsa.pub`<\/code> for the public key. If you don&#8217;t need to use a specific passphrase, you can press <strong>Enter<\/strong> to leave it empty. However, adding a passphrase adds an extra layer of security, making it necessary to provide the passphrase each time you use the key.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong><em>Step 2: Copying the Public Key to the Remote Server<\/em><\/strong><\/h5>\n\n\n\n<p>Now that you have generated your SSH key pair, you need to copy the public key to the remote server. To do this, you can use the <code>scp<\/code> command (Secure Copy Protocol) as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">scp ~\/.ssh\/id_rsa.pub username@remote_system_ip:~\/.ssh\/authorized_keys<\/mark><\/strong><\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>Replace <code>username<\/code> with your remote server username, and <code>remote_system_ip<\/code> with the actual IP address or domain name of the remote server. The command will copy the contents of your public key file (<code>id_rsa.pub<\/code>) to the <code>authorized_keys<\/code> file in the <code>.ssh<\/code> directory on the remote server.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><em><strong>Step 3: Connecting to the Remote Server using SSH Key Authentication<\/strong><\/em><\/h5>\n\n\n\n<p>With the public key copied to the remote server, you can now connect to it using SSH key authentication. Open a terminal and execute the following command:<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">ssh -p port username@remote_system_ip<\/mark><\/strong><\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>Replace <code>port<\/code> with the SSH port of the remote server (typically port 22 unless you have configured it differently), <code>username<\/code> with your remote server username, and <code>remote_system_ip<\/code> with the actual IP address or domain name of the remote server.<\/p>\n\n\n\n<p>If you have set a passphrase for your private key during Step 1, you&#8217;ll be prompted to enter it before establishing the SSH connection. Once you provide the correct passphrase (if applicable), the SSH client will use the private key to authenticate with the remote server, and if the public key matches what&#8217;s in the <code>authorized_keys<\/code> file, you&#8217;ll be granted access without needing to enter a password.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h4>\n\n\n\n<p>By following this step-by-step guide, you have successfully generated an SSH key pair, copied the public key to the remote server, and established an SSH connection using key-based authentication. Using SSH keys adds an extra layer of security to your remote connections and eliminates the need for passwords, making the whole process more secure and convenient.<\/p>\n\n\n\n<p>It&#8217;s recommended to use specialized hosting platforms like <a href=\"https:\/\/www.godaddy.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Godaddy<\/a>, <a href=\"https:\/\/www.hostinger.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hostinger<\/a>, <a href=\"https:\/\/aws.amazon.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">AWS<\/a>, or <a href=\"https:\/\/www.digitalocean.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">DigitalOcean<\/a>.<\/p>\n\n\n\n<p>Remember to keep your private key safe and never share it with anyone. Regularly updating your keys and using passphrases are good security practices that you should adopt to safeguard your systems from unauthorized access. Happy secure remote server management!<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<p>Also Read : <a href=\"https:\/\/techbanda.com\/blog\/deploy-your-django-website-to-netlify\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Deploy Your Django Website to Netlify<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to Set up SSH Public Key Auth for Remote Access Secure Shell (SSH) is a widely-used cryptographic network protocol [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":161,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[39,36,38,37,35],"class_list":["post-159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows","tag-authentication","tag-command-prompt","tag-shell","tag-ssh","tag-windows"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Set up SSH Public Key Auth for Remote Access - Tech Banda Blog&#039;s<\/title>\n<meta name=\"description\" content=\"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Set up SSH Public Key Auth for Remote Access - Tech Banda Blog&#039;s\" \/>\n<meta property=\"og:description\" content=\"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech Banda Blog&#039;s\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-06T10:15:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-20T04:45:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Basudev kar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Basudev kar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/\",\"url\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/\",\"name\":\"Set up SSH Public Key Auth for Remote Access - Tech Banda Blog's\",\"isPartOf\":{\"@id\":\"https:\/\/techbanda.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png\",\"datePublished\":\"2023-08-06T10:15:19+00:00\",\"dateModified\":\"2023-10-20T04:45:06+00:00\",\"author\":{\"@id\":\"https:\/\/techbanda.com\/blog\/#\/schema\/person\/659e018bc389d41fc5f45c25c4b721ac\"},\"description\":\"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.\",\"breadcrumb\":{\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage\",\"url\":\"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png\",\"contentUrl\":\"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png\",\"width\":1920,\"height\":1080,\"caption\":\"SSH-Public-Key-Authentication\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/techbanda.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Set up SSH Public Key Auth for Remote Access\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/techbanda.com\/blog\/#website\",\"url\":\"https:\/\/techbanda.com\/blog\/\",\"name\":\"Tech Banda Blog's\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/techbanda.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/techbanda.com\/blog\/#\/schema\/person\/659e018bc389d41fc5f45c25c4b721ac\",\"name\":\"Basudev kar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/techbanda.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d817fa6b5b51f9541ce2fc99566246de84b7f0061f5a163239e5e717abb01d6b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d817fa6b5b51f9541ce2fc99566246de84b7f0061f5a163239e5e717abb01d6b?s=96&d=mm&r=g\",\"caption\":\"Basudev kar\"},\"url\":\"https:\/\/techbanda.com\/blog\/author\/techadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Set up SSH Public Key Auth for Remote Access - Tech Banda Blog's","description":"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/","og_locale":"en_US","og_type":"article","og_title":"Set up SSH Public Key Auth for Remote Access - Tech Banda Blog's","og_description":"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.","og_url":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/","og_site_name":"Tech Banda Blog's","article_published_time":"2023-08-06T10:15:19+00:00","article_modified_time":"2023-10-20T04:45:06+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png","type":"image\/png"}],"author":"Basudev kar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Basudev kar","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/","url":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/","name":"Set up SSH Public Key Auth for Remote Access - Tech Banda Blog's","isPartOf":{"@id":"https:\/\/techbanda.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage"},"image":{"@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage"},"thumbnailUrl":"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png","datePublished":"2023-08-06T10:15:19+00:00","dateModified":"2023-10-20T04:45:06+00:00","author":{"@id":"https:\/\/techbanda.com\/blog\/#\/schema\/person\/659e018bc389d41fc5f45c25c4b721ac"},"description":"Enhance remote access security with SSH public key auth. Our guide offers a passwordless, secure, and convenient connection.","breadcrumb":{"@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#primaryimage","url":"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png","contentUrl":"https:\/\/techbanda.com\/blog\/wp-content\/uploads\/2023\/08\/SSH-Public-Key-Authentication.png","width":1920,"height":1080,"caption":"SSH-Public-Key-Authentication"},{"@type":"BreadcrumbList","@id":"https:\/\/techbanda.com\/blog\/ssh-public-key-auth-for-remote-access\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techbanda.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Set up SSH Public Key Auth for Remote Access"}]},{"@type":"WebSite","@id":"https:\/\/techbanda.com\/blog\/#website","url":"https:\/\/techbanda.com\/blog\/","name":"Tech Banda Blog's","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techbanda.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/techbanda.com\/blog\/#\/schema\/person\/659e018bc389d41fc5f45c25c4b721ac","name":"Basudev kar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techbanda.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d817fa6b5b51f9541ce2fc99566246de84b7f0061f5a163239e5e717abb01d6b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d817fa6b5b51f9541ce2fc99566246de84b7f0061f5a163239e5e717abb01d6b?s=96&d=mm&r=g","caption":"Basudev kar"},"url":"https:\/\/techbanda.com\/blog\/author\/techadmin\/"}]}},"views":50,"_links":{"self":[{"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":5,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":215,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions\/215"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/media\/161"}],"wp:attachment":[{"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techbanda.com\/blog\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}