How to authorize Local System Account for OpenSSH

We have Jenkins installed and want it to pull from bitbucket and github – authorization should happen through Open SSH (Public Keys).

Jenkins runs as Local System.

The problem

How to find and then place id_rsa into ~/.ssh? How to get it to add things to ~/.ss/known_hosts?

The solution

As always: fake it until you make it!

  1. Run this command in an elevated command prompt on the server, in order to start a command prompt as Local System user:

    sc create testsvc binpath= "cmd /K start" type= own type= interact && sc start testsvc & sc delete testsvc

    The Interactive Services Detection will now bring up a dialog (probably in the background) where it asks you to “View the message” in order to display the service session where the command window will run.

  2. Run echo %userprofile% to see where your storage is… In my case it is "C:\Windows\system32\config\systemprofile”.

    Odd, but true: Sadly, when i try to put the id_rsa file into that directory from my normal user session, it somehow doesn’t make it into the local system accounts profile.
  3. From here you can open the git bash by running C:\Program Files (x86)\Git\bin\sh –login –i
  4. Then run cd ~ to switch to your home directory.
  5. Then copy your id_rsa file here with a simple
    cp <id_rsa-location> .
  6. Now run ssh git@bitbucket.org in order to try to authenticate and accept the host as known host.

BTW: also make sure you run git.cmd, not git.exe!!

Other posts that helped (and confused) me:

Advertisement

Recent publications

A while since I posted about articles I wrote. If you know German, this might be interesting for you 🙂

Just a short translation of the topics:

  • Deklarativ bauen: About building .NET applications declaratively with Apache NPanday + Maven.
  • Vom Patch zum Committer: About enabling a good workflow for submitting patches to SVN-based OS projects using GIT, github and GIT-SVN.
  • Quellen anzapfen: Introduction to GIT and GIT-SVN
  • Aschenputtel ausstaffieren: About creating high-quality console applications.
  • Neuigkeiten zum Resharper 5: A “news” article on the history of refactoring tool support and JetBrains newest (at that time) ReSharper version.

 

July 2011

Bildschirmfoto 2011-06-10 um 14.15.52

Deklarativ bauen, Maven und NPanday, dotnetpro 07/2011, Seite 30


February 2011

Bildschirmfoto 2011-06-10 um 14.16.59

Vom Patch zum Committer, Open-Source Workflow mit Git + SVN, dotnetpro 02/2011, Seite 106


January 2011

Bildschirmfoto 2011-06-10 um 14.16.31

Quellen anzapfen, Einführung zu Open Source, git und git-svn, dotnetpro 01/2011, Seite 84


November 2010

Bildschirmfoto 2011-06-10 um 14.17.45

Aschenputtel ausstaffieren, Konsolenprogramme, Clean Code, dotnetpro 11/2010, Seite 56


September 2010

Bildschirmfoto 2011-06-10 um 14.17.28

Die Schlange im Tigerkäfig, Ko- und Kontravarianz in C#, dotnetpro 09/2010, Seite 68


April 2010

Bildschirmfoto 2011-06-10 um 14.18.50

Neuigkeiten zum ReSharper 5, dotnetMagazin + dotnet.de

How-to branch and patch SVN- or TFS/Codeplex-based open source projects with GIT (Part 1)

The last couple of weeks I worked a lot with NPanday which brings maven to .NET. But this post is not about NPanday but rather about the workflow for maintaining a personal branch and uploading patches.

I’m not a committer, but I had to do some changes to NPanday. I still want to version my changes. I also want to contribute patches, when I fix bugs that apply to the current trunk.

NPanday is hosted on Codeplex, and though accessible via the SvnBridge. So I chose to give git svn a try.

I also want to host my changes on github.

The Workflow

  • Once
    • Clone a svn repo to a local-git
    • Create a branch for svn updates, say codeplex
    • Create a GitHub repo and push both branches
  • Repeatedly
    • Do your work on master
    • Commit and push your work
    • Update codeplex from subversion and push it
    • Merge codeplex to master
  • Contribute and Commit
    • How to create and submit patches from our master
    • How to commit changes back to codeplex

The How-To

I don’t want to mess around with npanday, so I created a empty test-project on codeplex.: [SAMPLE PROJECT] Branch and Patch with GIT

Setup (Windows)

On mac you simply use mac ports, on linux I have no clue.

  • Install SVN binaries and add to %PATH% (download)

  • The binary mysys doesn’t come with git svn anymore, so you have to compile it yourself. Is not as hard as it sounds. Just download the fullinstall – it will run the compile for you. (download 1.7.0.2 , downloads) Don’t forget to add it to the path, too.

I’ll do everything on the command line. Red is SVN, green is GIT – they are in separate folders.

I use pictures. Type it yourself! It will help you to learn it.

Don’t be afraid reading the command line either. It’s like code! You’ll get used to it, so did I.

Once

Checkout and commit a text fileimage

Init and fetch the commited revision using svn git:

image

Now, since we want to do changes, lets create a branch codeplex but remain on master and do changes.

image 

We should make sure, that the branch codeplex is untouched:

image

I also created a project on github. So lets push it over there. Read how to setup your private key and connect here.

image

Now we have the two commits on the master:

tmp2E0B

And only one on codeplex:

tmpE826

Now we change our “subversion”-file:

image

And then we update it using git svn rebase on the codeplex branch. Sorry for not having accepted the certificate before. But its live! 🙂

image Result:

tmpD8EB

Now we want to have that change over on our work branch.

image

Voilá:

tmpF6A9

Now, this is our repo:

image

Enough for today. Let’s se what we covered:

Recap

  • Once
    • We initialized the empty codeplex repo with a single-line file.
    • Clone a svn repo to a local-git
      We used git svn init and fetch to get the codeplex contents in a local git repository.
    • Create a branch for svn updates, say codeplex
      We created the branch
    • Create a GitHub repo and push both branches
      We pushed both master and codeplex
  • Repeatedly
    • Do your work on master
      We added a file to our master.
    • Commit and push your work
      We pushed it to master. Both the source svn and codeplex branch remain untouched.
    • Update codeplex from subversion and push it
      We added a line and checked it into svn and then we got it into our codeplex branch did that.
    • Merge codeplex to master
      We did that too.

More soon! Probably next Friday:

  • Contribute and Commit
    • How to create and submit patches from our master
    • How to commit changes back to codeplex