{"id":9770,"date":"2020-01-30T14:20:33","date_gmt":"2020-01-30T14:20:33","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9770"},"modified":"2022-04-24T04:28:27","modified_gmt":"2022-04-24T04:28:27","slug":"how-to-setup-ssh-keys-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-setup-ssh-keys-on-ubuntu-linux\/","title":{"rendered":"Linux Tutorials: How to setup SSH keys on Ubuntu\/ Linux"},"content":{"rendered":"\n<p><strong>Introduction:<\/strong><br>If you want to clone a repository from gitlab, github or bitbucket in your Ubuntu machine then you may need to setup SSH Keys in ubuntu and add that key to gitlab, github or bitbucket to make the repository accessible from Ubuntu machine.<br><br><strong>Steps:<\/strong><br><strong>1. Login to the Ubuntu<\/strong> machine using SSH client like Putty<br><strong>2.<\/strong> Run: <code><strong>sudo -s<\/strong><\/code> (This is to be a root user)<br><strong>3.<\/strong> Run: <code><strong>cd \/root\/<\/strong><\/code><\/p>\n\n\n\n<p> <strong>4.<\/strong> <strong>Verify if .ssh file exists<\/strong> in the \/root dir <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"658\" height=\"232\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-63.png\" alt=\"\" class=\"wp-image-9771\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-63.png 658w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-63-300x106.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/figure>\n\n\n\n<p><strong>5. Generate SSH Key.<\/strong> Command: <code><strong>ssh-keygen<\/strong><\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"510\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-65.png\" alt=\"\" class=\"wp-image-9773\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-65.png 876w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-65-300x175.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-65-768x447.png 768w\" sizes=\"auto, (max-width: 876px) 100vw, 876px\" \/><\/figure>\n\n\n\n<p><strong>6. Move to \/root\/.ssh directory<\/strong>, Command: <code><strong>cd .ssh<\/strong><\/code><\/p>\n\n\n\n<p><strong>7. Verify if the id_rsa.pub was created successfully<\/strong> using command: <strong><code>ls<\/code><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"110\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-66.png\" alt=\"\" class=\"wp-image-9774\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-66.png 620w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-66-300x53.png 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/figure>\n\n\n\n<p><strong>8. Reterive the public ssh key to add it in gitlab, github or butbucket<\/strong> using command <strong><code>more id_rsa.pub<\/code><\/strong><br>You can simply copy the key and add them in gitlab, github or butbucket<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"77\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-67-1024x77.png\" alt=\"\" class=\"wp-image-9775\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-67-1024x77.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-67-300x23.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-67-768x58.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/image-67.png 1265w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>9. Git clone to check if you are able to clone the directory after adding the key in gitlab, github or butbucket using commands:<br><code><strong>exit<\/strong><\/code><br><strong><code>sudo git clone git@&lt;Your_Repository_SSH_Clone_URL&gt;<\/code><\/strong><br><\/p>\n\n\n\n<p>Thanks for reading, I hope you enjoyed the article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:If you want to clone a repository from gitlab, github or bitbucket in your Ubuntu machine then you may need to setup SSH Keys in ubuntu and add that key&#8230; <\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4957],"tags":[],"class_list":["post-9770","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9770"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9770\/revisions"}],"predecessor-version":[{"id":29697,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9770\/revisions\/29697"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}