{"id":2523,"date":"2018-04-24T22:03:55","date_gmt":"2018-04-25T03:03:55","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=2523"},"modified":"2018-04-24T22:03:55","modified_gmt":"2018-04-25T03:03:55","slug":"case-of-the-mysterious-git-repo","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2018\/04\/case-of-the-mysterious-git-repo\/","title":{"rendered":"The Case of the Mysterious Git Repo"},"content":{"rendered":"<p>I&#8217;m migrating scripts from one CentOS host to another. (The old one is CentOS 6 and the new one is CentOS 7.) One of the items I want to move is a script that&#8217;s part of a git repo.<\/p>\n<p>I know it&#8217;s a git repo because it has a <code>.git<\/code> directory. The directory and files are owned by a local user, <code>luser1<\/code>.<\/p>\n<p>Where did this git repo come from?<\/p>\n<p>You can call <code>git config -l<\/code> and it will tell you things about the repo, including the <code>remote.origin.url<\/code>. Now I can tell that it came from my GitHub Enterprise (GHE) instance.<\/p>\n<p>But it doesn&#8217;t tell you who created it. And <code>luser1<\/code> doesn&#8217;t exist on my GitHub Enterprise instance.<\/p>\n<p>I tried to clone it on the new host, just to see what would happen:<\/p>\n<pre><code>$ sudo -u luser1 git clone git@github.osric.net:team1\/the-sauce.git<\/code><\/pre>\n<p>Result:<\/p>\n<pre><code>fatal: Could not read from remote repository.\r\n\r\nPlease make sure you have the correct access rights\r\nand the repository exists.<\/code><\/pre>\n<p>Somehow luser1 is able to interact with this repo on the old host, even though the user doesn&#8217;t exist in GHE.<\/p>\n<p>Fortunately the local repo has some history:<\/p>\n<pre><code>$ head -n1 .git\/logs\/HEAD<\/code><\/pre>\n<p>Result:<\/p>\n<pre><code>0000000000000000000000000000000000000000 ab509345a16d987dac10987c4bc2df0c0dfb3ed9 luser1 luser1 &lt;luser1@oldhost.osric.net&gt; 1505633110 -0500   clone: from git@github.osric.net:team1\/the-sauce.git<\/code><\/pre>\n<p>Right there there it is, all the info I wanted! Except that&#8217;s the same user, the user that doesn&#8217;t even exist in GitHub Enterprise.<\/p>\n<p>Or does it? I went looking at some of the other users in my GitHub Enterprise instance. There were a few system accounts, and when I checked some of them had several SSH keys associated with the accounts. One of the SSH key fingerprints even said <code>luser1<\/code>.<\/p>\n<p>I wanted to compare that key fingerprint to the key in <code>\/home\/luser1\/.ssh\/id_rsa.pub<\/code>. I can never remember how to do that, but StackOverflow had the answer on <a href=\"https:\/\/stackoverflow.com\/questions\/9607295\/how-do-i-find-my-rsa-key-fingerprint\">How do I find my RSA key fingerprint?<\/a><\/p>\n<pre><code>$ ssh-keygen -lf \/home\/luser1\/.ssh\/id_rsa.pub<\/code><\/pre>\n<p>Result:<\/p>\n<pre><code>2048 bb:fc:1c:03:17:5f:67:4f:1f:0b:50:5a:9f:f9:30:e5 \/home\/luser1\/.ssh\/id_rsa.pub (RSA)<\/code><\/pre>\n<p>The fingerprint matches! The SSH key was added to a completely different username in GitHub Enterprise which <em>does<\/em> have access to the repo.<\/p>\n<p>That works, but why would someone do that? Convenience, I assume, but it wasn&#8217;t obvious when I needed to reverse-engineer it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You have a git repository, but you don&#8217;t know how it got there, where it came from, and who created it using which credentials. How can you track down these details? I found a few commands that helped me track down the origins of a repo, at least in one particular case.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[497],"tags":[314],"class_list":["post-2523","post","type-post","status-publish","format-standard","hentry","category-git","tag-git"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":8,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"predecessor-version":[{"id":2541,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/2523\/revisions\/2541"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}