{"id":1161,"date":"2023-09-11T13:44:48","date_gmt":"2023-09-11T13:44:48","guid":{"rendered":"http:\/\/oqtacore-blog-473533498.us-east-1.elb.amazonaws.com\/?p=1161"},"modified":"2025-05-22T10:34:42","modified_gmt":"2025-05-22T10:34:42","slug":"how-to-use-github-deploy-keys","status":"publish","type":"post","link":"https:\/\/oqtacore.com\/blog\/how-to-use-github-deploy-keys\/","title":{"rendered":"How to Use GitHub Deploy Keys"},"content":{"rendered":"<h1>How to Use GitHub Deploy Keys on Linux and Windows<\/h1>\n<p>Learn how to set up GitHub deploy keys on both Linux and Windows systems in this detailed, step-by-step guide.<\/p>\n<p><!--more--><\/p>\n<p>We will first walk you through the setup process on Linux, followed by a guide to setting up deploy keys on Windows.<\/p>\n<p>GitHub deploy keys offer a secure and convenient method of granting access to your GitHub repositories. Different projects utilize deploy keys to maintain a high level of security, ensuring that access is restricted to specified individuals or systems. Instead of using personal GitHub accounts, which can potentially be compromised leading to unauthorized access to all repositories a person has access to, deploy keys restrict access to a single repository, providing a more secure environment. Moreover, deploy keys simplify the automation of pulling code into production or CI\/CD pipelines without having to manage individual permissions.<\/p>\n<p>Deploy keys come with various settings on GitHub that help in enhancing security. They can be set to &#8220;read-only,&#8221; which allows pulling of the repository contents but not pushing any changes, thus safeguarding the repository from any unwanted alterations. Also, by enabling deploy keys at an organizational level, you streamline access across multiple repositories, which can be a boon for larger projects.<\/p>\n<p>Let\u2019s delve deeper to understand how you can set up GitHub deploy keys on Linux and Windows systems.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_Use_GitHub_Deploy_Keys_on_Linux_and_Windows\"><\/span>How to Use GitHub Deploy Keys on Linux and Windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Learn how to set up GitHub deploy keys on both Linux and Windows systems in this detailed, step-by-step guide. We will first walk you through the setup process on Linux, followed by a guide to setting up deploy keys on Windows.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Setting_Up_GitHub_Deploy_Keys_on_Linux\"><\/span>Setting Up GitHub Deploy Keys on Linux<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Follow these step-by-step instructions to set up GitHub deploy keys on a Linux system:<\/p>\n<h3>Step 1: Install the Necessary Tools<\/h3>\n<p>Before we begin, ensure that Git and SSH are installed on your Linux system. Open a terminal and run the following commands to install them:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo apt-get update\r\nsudo apt-get install git\r\nsudo apt-get install openssh-server<\/pre>\n<h3>Step 2: Generate SSH Keys<\/h3>\n<p>Use the `ssh-keygen` command to generate a new SSH key pair. You will use this key pair as your deploy key.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"\r\n<\/pre>\n<p>Follow the on-screen prompts, opting to save the key with a distinct name to differentiate it from other SSH keys.<\/p>\n<h3>Step 3: Add the SSH Key to the SSH Agent<\/h3>\n<p>Add your new key to the SSH agent with the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">ssh-add ~\/.ssh\/your-ssh-key-filename\r\n<\/pre>\n<h3>Step 4: Add the SSH Key to Your GitHub Repository<\/h3>\n<p>Navigate to your GitHub repository and go to &#8220;Settings&#8221; &gt; &#8220;Deploy keys&#8221; &gt; &#8220;Add deploy key&#8221;. Here, add a title for your key and paste the public key, which you can get using the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">cat ~\/.ssh\/your-ssh-key-filename.pub\r\n<\/pre>\n<p>Click &#8220;Add key&#8221; to save the deploy key.<\/p>\n<h3>Step 5: Clone Your Repository<\/h3>\n<p>Now clone your repository using the SSH URL:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git clone git@github.com:your-username\/your-repository.git\r\n<\/pre>\n<p>You should now have configured GitHub deploy keys on your Linux system successfully.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"_Setting_Up_GitHub_Deploy_Keys_on_Windows\"><\/span>## Setting Up GitHub Deploy Keys on Windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here&#8217;s how you can set up GitHub deploy keys on a Windows system:<\/p>\n<h3>Step 1: Install Git for Windows<\/h3>\n<p>Download and install [Git for Windows](https:\/\/gitforwindows.org\/) by following the on-screen instructions.<\/p>\n<h3>Step 2: Generate SSH Keys<\/h3>\n<p>Open Git Bash and generate a new SSH key pair using the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"\r\n<\/pre>\n<h3>Step 3: Add the SSH Key to the SSH Agent<\/h3>\n<p>Start the SSH agent in the background and add your SSH key:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">eval $(ssh-agent -s)\r\nssh-add ~\/.ssh\/your-ssh-key-filename\r\n<\/pre>\n<h3>Step 4: Add the SSH Key to Your GitHub Repository<\/h3>\n<p>On your GitHub repository, navigate to &#8220;Settings&#8221; &gt; &#8220;Deploy keys&#8221; &gt; &#8220;Add deploy key&#8221;. Provide a title and paste the contents of your public SSH key, which can be displayed using the command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">cat ~\/.ssh\/your-ssh-key-filename.pub\r\n<\/pre>\n<h3>Step 5: Clone Your Repository<\/h3>\n<p>Clone your repository using the SSH URL:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">git clone git@github.com:your-username\/your-repository.git\r\n<\/pre>\n<p>Congratulations, you have successfully set up GitHub deploy keys on your Windows system. Ensure to always keep your private keys secure and to add your public key only to the necessary GitHub repositories to maintain a secure environment.<\/p>\n<p>At the end of the guide, we trust that you are well-versed with GitHub deploy keys and their setup on Linux and Windows. Always remember, the prudent use of deploy keys not only secures your project but also facilitates a seamless development workflow by leveraging the different settings available for deploy keys on GitHub. Make the most of deploy keys to enhance your project&#8217;s security and workflow efficiency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Use GitHub Deploy Keys on Linux and Windows Learn how to set up GitHub deploy keys on both Linux and Windows systems in this detailed, step-by-step guide.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_mo_disable_npp":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1161","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":{"image":1168},"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/1161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/comments?post=1161"}],"version-history":[{"count":8,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/1161\/revisions"}],"predecessor-version":[{"id":1910,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/posts\/1161\/revisions\/1910"}],"wp:attachment":[{"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/media?parent=1161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/categories?post=1161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oqtacore.com\/blog\/wp-json\/wp\/v2\/tags?post=1161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}