{"id":9,"date":"2013-04-29T13:16:56","date_gmt":"2013-04-29T11:16:56","guid":{"rendered":"http:\/\/hesmid.nl\/test\/?p=9"},"modified":"2022-04-24T13:54:37","modified_gmt":"2022-04-24T11:54:37","slug":"setup-ssh-for-git","status":"publish","type":"post","link":"https:\/\/hesmid.nl\/test\/setup-ssh-for-git\/","title":{"rendered":"Setup SSH"},"content":{"rendered":"<p>Follow the steps in this post on bitbucket.org<\/p>\n<p><a href=\"https:\/\/support.atlassian.com\/bitbucket-cloud\/docs\/set-up-an-ssh-key\/\">https:\/\/support.atlassian.com\/bitbucket-cloud\/docs\/set-up-an-ssh-key\/<\/a><\/p>\n<p><del>There is also a script in there to configure your bash shell to automatically start the agent when launch the shell.<\/del><\/p>\n<p>Local: go to .ssh directory<\/p>\n<pre lang=\"bash\">ssh-keygen\n<\/pre>\n<p>Name your key and give a password<\/p>\n<p id=\"Step-2.-Add-the-key-to-the-ssh-agent.1\"><strong>Add the key to the ssh-agent:<\/strong><\/p>\n<pre><span class=\"code\">ssh-add<\/span> ~\/.ssh\/id_rsa # or whatever the name of the key is<\/pre>\n<p>tip: create an alias sshaddxx<\/p>\n<p><strong>How to add the public key to bitbucket:<\/strong><\/p>\n<ul>\n<li>\n<p data-renderer-start-pos=\"7375\">From Bitbucket, choose <strong>Personal settings<\/strong>\u00a0from your avatar in the lower left.<\/p>\n<\/li>\n<li>https:\/\/bitbucket.org\/account\/settings\/<\/li>\n<li>\n<p data-renderer-start-pos=\"7455\">Click\u00a0<strong>SSH keys<\/strong>.<br \/>\nIf you&#8217;ve already added keys, you&#8217;ll see them on this page.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"7534\">In your terminal window, copy the contents of your public key file. If you renamed the key, replace <span class=\"code\">id_rsa.pub<\/span> with the public key file name.<\/p>\n<p data-renderer-start-pos=\"7677\">On Linux, you can <span class=\"code\">cat<\/span> the contents:<\/p>\n<p data-renderer-start-pos=\"7714\"><span class=\"code\">$ cat ~\/.ssh\/id_rsa.pub <\/span><\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"7852\">Select and copy the key output in the clipboard.<br \/>\nIf you have problems with copy and paste, you can open the file directly with Notepad. Select the contents of the file (just avoid selecting the end-of-file characters).<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"8074\">From Bitbucket, click <strong>Add key<\/strong>.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"8108\">Enter a\u00a0<strong>Label<\/strong>\u00a0for your new key, for example,\u00a0<span class=\"code\">Default public key<\/span>.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"8176\">Paste the copied public key into the\u00a0SSH<strong> Key<\/strong>\u00a0field.<br \/>\nYou may see an email address on the last line when you paste. It doesn&#8217;t matter whether or not you include the email address in the <strong>Key<\/strong>.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"8368\">Click\u00a0<strong>Save<\/strong>.<br \/>\nBitbucket sends you an email to confirm the addition of the key.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"8448\">Return to the terminal window and verify your configuration and username by entering the following command:<\/p>\n<p data-renderer-start-pos=\"8557\"><span class=\"code\">$ ssh -T git@bitbucket.org<\/span><\/p>\n<p data-renderer-start-pos=\"8590\">The command message tells you which of your Bitbucket accounts can log in with that key.<\/p>\n<div class=\"code-block \"><\/div>\n<\/li>\n<\/ul>\n<ol class=\"ak-ol\">\n<li value=\"9\">\n<div class=\"code-block \"><code><\/p>\n<p>            conq: logged in as emmap1.<br \/>\nYou can use git or hg to connect to Bitbucket. Shell access is disabled.<\/p>\n<p><\/code><\/div>\n<p data-renderer-start-pos=\"8805\">If you get an error message with\u00a0<span class=\"code\">Permission denied (publickey)<\/span>, check the\u00a0<a class=\"sc-drMfKT ldtwIt\" title=\"https:\/\/confluence.atlassian.com\/bitbucket\/troubleshoot-ssh-issues-271943403.html\" href=\"https:\/\/confluence.atlassian.com\/bitbucket\/troubleshoot-ssh-issues-271943403.html\">Troubleshoot SSH issues<\/a>\u00a0page for help.<\/p>\n<\/li>\n<\/ol>\n<p data-renderer-start-pos=\"8923\">Now that you&#8217;ve got an SSH key set up, use the SSH URL the next time you <a class=\"sc-drMfKT ldtwIt\" title=\"https:\/\/confluence.atlassian.com\/bitbucket\/clone-a-repository-223217891.html\" href=\"https:\/\/confluence.atlassian.com\/bitbucket\/clone-a-repository-223217891.html\">clone a repository<\/a>. If you already have a repository that you cloned over HTTPS, <a class=\"sc-drMfKT ldtwIt\" title=\"https:\/\/confluence.atlassian.com\/bitbucket\/change-the-remote-url-to-your-repository-794212774.html\" href=\"https:\/\/confluence.atlassian.com\/bitbucket\/change-the-remote-url-to-your-repository-794212774.html\">change the remote URL for your repository<\/a> to use its SSH URL.<\/p>\n<div class=\"ak-editor-panel\" data-panel-type=\"info\"><\/div>\n<div class=\"ak-editor-panel__content\">\n<p data-renderer-start-pos=\"9140\"><strong>Edit an SSH key<\/strong><\/p>\n<p data-renderer-start-pos=\"9157\">After you add a key, you can edit the key&#8217;s\u00a0<strong>Label<\/strong>\u00a0but not the key itself. To change the key&#8217;s contents, you need to delete and re-add the key.<\/p>\n<\/div>\n<p><strong>How to add public keys to the server:<\/strong><!--more--><\/p>\n<pre lang=\"bash\">$ scp -p id_rsa.pub remoteuser@remotehost:\n$ ssh remoteuser@remotehost\nPassword: ********\nremotehost$ mkdir -p ~\/.ssh #If it doesn't already exist\nremotehost$ chmod 700 ~\/.ssh\nremotehost$ cat id_rsa.pub &gt;&gt; ~\/.ssh\/authorized_keys  #(Appending)\nremotehost$ chmod 600 ~\/.ssh\/authorized_keys\nremotehost$ mv id_rsa.pub ~\/.ssh #Optional, just to be organized\nremotehost$ logout\n<\/pre>\n<p><strong>todo:<br \/>\n<\/strong><\/p>\n<p>Automatically add keys to some kind of keychain<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow the steps in this post on bitbucket.org https:\/\/support.atlassian.com\/bitbucket-cloud\/docs\/set-up-an-ssh-key\/ There is also a script in there to configure your bash shell to automatically start the agent when launch the shell. Local: go to .ssh directory ssh-keygen Name your key and give a password Add the key to the ssh-agent: ssh-add ~\/.ssh\/id_rsa # or whatever the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7,4],"tags":[9,3,5,8],"acf":[],"_links":{"self":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/9"}],"collection":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":19,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":15046,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/9\/revisions\/15046"}],"wp:attachment":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}