Self-hosting a C# Nancy Server on Linux

Sinatra is a popular and wonderful web application framework that has spawned a number of copycat frameworks. You can write large websites or REST servers with it. While it is a framework only for Ruby, there are alternatives for other languages, Spark Java for Java, Lavarel for PHP, etc. For C#, Nancy is the choice, and you can avoid using ASP.NET if you’d like. This post shows how to set up a “Hello world!” Nancy project that will build and run on Ubuntu and Windows.

Prerequisites:

Method:

  1. In your Windows host machine, start Visual Studio.
  2. In Visual Studio:
    1. Create a new C# console application “hn” within the mapped directory for the virtual machine.
    2. Replace the contents of Program.cs with the following code:
      using System;
      using System.Collections.Generic;
      using Nancy;
      using Nancy.Hosting.Self;
      
      namespace hn
      {
          public class SampleModule : Nancy.NancyModule
          {
              public SampleModule()
              {
                  Get["/"] = _ => "Hello World!";
              }
          }
      
          class Program
          {
              static void Main(string[] args)
              {
                  var uri = new Uri("http://localhost:80");
                  List list_uri = new List();
                  list_uri.Add(uri);
      
                  HostConfiguration hostConfigs = new HostConfiguration()
                  {
                      UrlReservations = new UrlReservations() { CreateAutomatically = true }
                  };
      
                  using (NancyHost host = new NancyHost(new DefaultNancyBootstrapper(), hostConfigs, list_uri.ToArray()))
                  {
                      host.Start();
                      foreach (Uri u in list_uri)
                          Console.WriteLine(u);
                      Console.WriteLine("Press any [Enter] to close the host.");
                      Console.ReadLine();
                  }
              }
          }
      }
      
      
    3. In order for this to compile, you will need to add two packages using the Package Manager.
      1. Start the Package Manager in Visual Studio.
      2. At the prompt, type Install-Package Nancy and Install-Package Nancy.Hosting.Self.
    4. Compile and run.
    5. In a browser, type in “http://localhost/”.
      1. Verify that your browser displays “Hello world!”.
  3. In the virtual machine guest:
    1. Open a Terminal.
    2. cd <mapped-directory>/<project-directory>
      1. Make sure the directory is mapped and you see the new project.
    3. xbuild
    4. mono bin/Debug/<project-executable>
    5. In a browser, type in “http://localhost/”.
      1. Verify that your browser displays “Hello world!”.

 

dokku@kukku:/vagrant/hn$ ls
App.config  bin  hn.csproj  hn.sln  obj  packages  packages.config  Program.cs  Properties
dokku@kukku:/vagrant/hn$ xbuild /target:Clean
XBuild Engine Version 12.0
Mono, Version 4.2.2.0
Copyright (C) 2005-2013 Various Mono authors

Build started 2/24/2016 10:20:58 AM.
__________________________________________________
Project "/vagrant/hn/hn.sln" (Clean target(s)):
	Target ValidateSolutionConfiguration:
		Building solution configuration "Debug|Any CPU".
	Target Clean:
		Project "/vagrant/hn/hn.csproj" (Clean target(s)):
/vagrant/hn/hn.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.
			Target CoreClean:
				Deleting file '/vagrant/hn/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs'
				Deleting file '/vagrant/hn/obj/Debug/hn.exe'
				Deleting file '/vagrant/hn/obj/Debug/hn.exe.mdb'
				Deleting file '/vagrant/hn/obj/Debug/hn.csproj.FilesWrittenAbsolute.txt'
		Done building project "/vagrant/hn/hn.csproj".
Done building project "/vagrant/hn/hn.sln".

Build succeeded.

Warnings:

/vagrant/hn/hn.sln (Clean) ->
(Clean target) ->
/vagrant/hn/hn.csproj (Clean) ->

	/vagrant/hn/hn.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.

	 1 Warning(s)
	 0 Error(s)

Time Elapsed 00:00:00.5218600
dokku@kukku:/vagrant/hn$ xbuild
XBuild Engine Version 12.0
Mono, Version 4.2.2.0
Copyright (C) 2005-2013 Various Mono authors

Build started 2/24/2016 10:21:05 AM.
__________________________________________________
Project "/vagrant/hn/hn.sln" (default target(s)):
	Target ValidateSolutionConfiguration:
		Building solution configuration "Debug|Any CPU".
	Target Build:
		Project "/vagrant/hn/hn.csproj" (default target(s)):
/vagrant/hn/hn.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.
			Target PrepareForBuild:
				Configuration: Debug Platform: AnyCPU
			Target GenerateSatelliteAssemblies:
			No input files were specified for target GenerateSatelliteAssemblies, skipping.
			Target CoreCompile:
				Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/hn.exe Program.cs Properties/AssemblyInfo.cs obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /target:exe /define:"DEBUG;TRACE" /nostdlib /platform:AnyCPU /reference:packages/Nancy.1.4.3/lib/net40/Nancy.dll /reference:packages/Nancy.Hosting.Self.1.4.1/lib/net40/Nancy.Hosting.Self.dll /reference:/usr/lib/mono/4.5/System.dll /reference:/usr/lib/mono/4.5/System.Xml.Linq.dll /reference:/usr/lib/mono/4.5/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5/System.Data.dll /reference:/usr/lib/mono/4.5/System.Net.Http.dll /reference:/usr/lib/mono/4.5/System.Xml.dll /reference:/usr/lib/mono/4.5/System.Core.dll /reference:/usr/lib/mono/4.5/mscorlib.dll /warn:4
			Target _CopyAppConfigFile:
			Skipping target "_CopyAppConfigFile" because its outputs are up-to-date.
			Target DeployOutputFiles:
				Copying file from '/vagrant/hn/obj/Debug/hn.exe.mdb' to '/vagrant/hn/bin/Debug/hn.exe.mdb'
				Copying file from '/vagrant/hn/obj/Debug/hn.exe' to '/vagrant/hn/bin/Debug/hn.exe'
		Done building project "/vagrant/hn/hn.csproj".
Done building project "/vagrant/hn/hn.sln".

Build succeeded.

Warnings:

/vagrant/hn/hn.sln (default targets) ->
(Build target) ->
/vagrant/hn/hn.csproj (default targets) ->

	/vagrant/hn/hn.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.

	 1 Warning(s)
	 0 Error(s)

Time Elapsed 00:00:01.0865300
dokku@kukku:/vagrant/hn$ mono bin/Debug/hn.exe

Unhandled Exception:
System.Net.Sockets.SocketException: Access denied
  at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end)  in :0 
  at System.Net.EndPointListener..ctor (System.Net.IPAddress addr, Int32 port, Boolean secure)  in :0 
  at System.Net.EndPointManager.GetEPListener (System.String host, Int32 port, System.Net.HttpListener listener, Boolean secure)  in :0 
  at System.Net.EndPointManager.AddPrefixInternal (System.String p, System.Net.HttpListener listener)  in :0 
  at System.Net.EndPointManager.AddListener (System.Net.HttpListener listener)  in :0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: Access denied
  at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end)  in :0 
  at System.Net.EndPointListener..ctor (System.Net.IPAddress addr, Int32 port, Boolean secure)  in :0 
  at System.Net.EndPointManager.GetEPListener (System.String host, Int32 port, System.Net.HttpListener listener, Boolean secure)  in :0 
  at System.Net.EndPointManager.AddPrefixInternal (System.String p, System.Net.HttpListener listener)  in :0 
  at System.Net.EndPointManager.AddListener (System.Net.HttpListener listener)  in :0 
dokku@kukku:/vagrant/hn$ sudo mono bin/Debug/hn.exe
http://localhost/
Press any [Enter] to close the host.

2016-02-24 (1)

 

Code for this example:

For more information:

 

Getting C# on Friggin’ Linux Working

If you like C#, and want to program using it across all platforms–including Linux–it’s easy using the Mono runtime! The details of the Mono project I won’t go into detail here, but rather only show how to set up a “Hello world!” project that will build and run on Ubuntu. Note: MonoProject is an IDE for Mono projects. I highly recommend you install that.

Prerequisites:

There are three options you can use to get the source project onto the virtual machine: (1) Use Visual Studio to create a Hello World program, then set up a mapped folder in VirtualBox that contains the project. (2) Use Visual Studio to create a Hello World program, then use Git to clone the repository onto the guest machine. If you’d like, you can skip this step, and use the example at https://bitbucket.org/ken_domino/hw/overview. (3) Use MonoProject to create a Hello World program from scratch on Ubuntu.

Method:

  1. In your Windows host machine, start Visual Studio.
  2. In Visual Studio:
    1. Create a new C# console application within the mapped directory for the virtual machine.
    2. Add System.Console.WriteLine(“Hello world!”); to the main method.
    3. Compile and run to verify that it works.
  3. Let’s set up Mono on the guest machine. In the virtual machine:
    1. Open a Terminal.
    2. cd <mapped-directory>/<project-directory>
      1. Make sure the directory is mapped and you see the new project.
    3. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
      1. You are creating a package repository for Mono.
      2. These instructions are from the Mono Project install for Ubuntu.
    4. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
    5. sudo apt-get update
    6. sudo apt-get install mono-complete
  4. Let’s now build the Hello World program. Use one of the three methods I mentioned above. Then…
    1. xbuild
      1. xbuild” is Mono’s version of “msbuild“.
    2. mono bin/Debug/<project-executable>
      1. You should see the “Hello world!” in the terminal.
  5. Install the MonoDevelop application if you want to have an IDE for C# on Linux. It is similar to Xamarin Studio. You can then open the project in MonoDevelop.
    1. sudo apt-get install monodevelop
  6. Install the XSP4 server if you want to write ASP.NET projects.
    1. sudo apt-get install mono-xsp4

 

dokku@kukku:/vagrant/hw$ which mono
/usr/bin/mono
dokku@kukku:/vagrant/hw$ mono --version
Mono JIT compiler version 4.2.2 (Stable 4.2.2.30/996df3c Mon Feb 15 17:30:30 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
dokku@kukku:/vagrant/hw$ which mono
/usr/bin/mono
dokku@kukku:/vagrant/hw$ mono --version
Mono JIT compiler version 4.2.2 (Stable 4.2.2.30/996df3c Mon Feb 15 17:30:30 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
dokku@kukku:/vagrant/hw$ xbuild /target:Clean
XBuild Engine Version 12.0
Mono, Version 4.2.2.0
Copyright (C) 2005-2013 Various Mono authors

Build started 2/24/2016 9:11:49 AM.
__________________________________________________
Project "/vagrant/hw/hw.sln" (Clean target(s)):
	Target ValidateSolutionConfiguration:
		Building solution configuration "Debug|Any CPU".
	Target Clean:
		Project "/vagrant/hw/hw.csproj" (Clean target(s)):
/vagrant/hw/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.
			Target CoreClean:
				Deleting file '/vagrant/hw/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs'
				Deleting file '/vagrant/hw/bin/Debug/hw.exe.config'
				Deleting file '/vagrant/hw/bin/Debug/hw.exe.mdb'
				Deleting file '/vagrant/hw/bin/Debug/hw.exe'
				Deleting file '/vagrant/hw/obj/Debug/hw.exe'
				Deleting file '/vagrant/hw/obj/Debug/hw.exe.mdb'
				Deleting file '/vagrant/hw/obj/Debug/hw.csproj.FilesWrittenAbsolute.txt'
		Done building project "/vagrant/hw/hw.csproj".
Done building project "/vagrant/hw/hw.sln".

Build succeeded.

Warnings:

/vagrant/hw/hw.sln (Clean) ->
(Clean target) ->
/vagrant/hw/hw.csproj (Clean) ->

	/vagrant/hw/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.

	 1 Warning(s)
	 0 Error(s)

Time Elapsed 00:00:00.5173490
dokku@kukku:/vagrant/hw$ ls -R
.:
App.config  bin  hw.csproj  hw.sln  obj  Program.cs  Properties

./bin:
Debug

./bin/Debug:
hw.pdb  hw.vshost.exe  hw.vshost.exe.config  hw.vshost.exe.manifest

./obj:
Debug

./obj/Debug:
DesignTimeResolveAssemblyReferencesInput.cache  TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs  TempPE
hw.csproj.FileListAbsolute.txt                  TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
hw.csprojResolveAssemblyReference.cache         TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

./obj/Debug/TempPE:

./Properties:
AssemblyInfo.cs
dokku@kukku:/vagrant/hw$ xbuild /target:Rebuild
XBuild Engine Version 12.0
Mono, Version 4.2.2.0
Copyright (C) 2005-2013 Various Mono authors

Build started 2/24/2016 9:12:19 AM.
__________________________________________________
Project "/vagrant/hw/hw.sln" (Rebuild target(s)):
	Target ValidateSolutionConfiguration:
		Building solution configuration "Debug|Any CPU".
	Target Rebuild:
		Project "/vagrant/hw/hw.csproj" (Rebuild target(s)):
/vagrant/hw/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.
			Target PrepareForBuild:
				Configuration: Debug Platform: AnyCPU
			Target GenerateSatelliteAssemblies:
			No input files were specified for target GenerateSatelliteAssemblies, skipping.
			Target CoreCompile:
				Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/hw.exe Program.cs Properties/AssemblyInfo.cs obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /target:exe /define:"DEBUG;TRACE" /nostdlib /platform:AnyCPU /reference:/usr/lib/mono/4.5/System.dll /reference:/usr/lib/mono/4.5/System.Xml.Linq.dll /reference:/usr/lib/mono/4.5/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5/System.Data.dll /reference:/usr/lib/mono/4.5/System.Net.Http.dll /reference:/usr/lib/mono/4.5/System.Xml.dll /reference:/usr/lib/mono/4.5/System.Core.dll /reference:/usr/lib/mono/4.5/mscorlib.dll /warn:4
			Target _CopyAppConfigFile:
				Copying file from '/vagrant/hw/App.config' to '/vagrant/hw/bin/Debug/hw.exe.config'
			Target DeployOutputFiles:
				Copying file from '/vagrant/hw/obj/Debug/hw.exe.mdb' to '/vagrant/hw/bin/Debug/hw.exe.mdb'
				Copying file from '/vagrant/hw/obj/Debug/hw.exe' to '/vagrant/hw/bin/Debug/hw.exe'
		Done building project "/vagrant/hw/hw.csproj".
Done building project "/vagrant/hw/hw.sln".

Build succeeded.

Warnings:

/vagrant/hw/hw.sln (Rebuild) ->
(Rebuild target) ->
/vagrant/hw/hw.csproj (Rebuild) ->

	/vagrant/hw/hw.csproj:  warning : Project has unknown ToolsVersion '14.0'. Using the default tools version '4.0' instead.

	 1 Warning(s)
	 0 Error(s)

Time Elapsed 00:00:01.1014250
dokku@kukku:/vagrant/hw$ ls -l bin/Debug/hw.exe
-rwxrwxrwx 1 dokku dokku 4096 Feb 24 09:12 bin/Debug/hw.exe
dokku@kukku:/vagrant/hw$ mono !$
mono bin/Debug/hw.exe
Hello world!
dokku@kukku:/vagrant/hw$ 

 

For more information:

 

Getting SSH/Git Clients on Friggin’ Windows Working

 

Secure Shell (SSH) is a network protocol used ubiquitously, e.g., github.com, bitbucket.com, etc. If you use Git or Hg, it’s nice to set up SSH because you can avoid having to re-enter your user id and password every time you clone the repository. (Or, if you are really desperate, encode the user id and password in the URI for the repository.) While there may be a lot of information (e.g., here and here) on how to set this up, it’s almost always Linux-centric, using ssh, ssh-add, ssh-keygen commands. Cygwin has an implementation which looks just like the Linux toolset, but Putty is the SSH system most use on Windows. Unfortunately, Git checks the environmental variables, and special cases the connection (see the kludges in git_connect in connect.c). So, if you try Git from Cygwin, it may not use the same SSH system in some other environment, like SourceTree. (If you look for “git.exe” in your PC, it’s sprinkled throughout.) If you didn’t know that and use Windows, God help you because you can spend days trying to figure out why things don’t work while sifting through the mountains of useless information! This protocol outlines the steps involved to set up SSH for both Cygwin and Putty.

Prerequisites:

  • Cygwin installed
  • Account on Github.com
  • Git installed (https://git-scm.com/downloads)
  • Git GUI (https://git-scm.com/downloads/guis). I recommend SourceTree (https://www.sourcetreeapp.com/).

Method:

    1. Open a Cygwin Terminal, and execute the following commands in order presented…
    2. which ssh
      1. Note: Verify that you have SSH installed for Cygwin. If not, go to http://cygwin.com, download the installer, run it and install SSH.
    3. I HIGHLY recommend you use Pageant. Place in your ~/.bashrc file eval $(/usr/local/bin/ssh-pageant -ra $TEMP/.ssh-pageant)., See https://github.com/cuviper/ssh-pageant.
      1. If you don’t plan on using Pageant, eval `ssh-agent -s`; ssh-add -L
      2. Note: look at the output to see if there are any keys added. There may or may not, it doesn’t matter because you’re going to generate and add a new key here.
    4. cd ~/.ssh
      1. Note: If you don’t have the directory, execute cd, then mkdir .ssh to create one, then cd .ssh.
    5.  ssh-keygen -t rsa
    6. On the prompts, you can just return for each thing prompted for.
    7. ls
      1. Note: Verify you have id_rsa, id_rsa.pub (or the file name you entered above) generated.
    8. cat id_rsa.pub # (or the file you entered above)
      1. Verify the key is not empty.
    9. ssh-add
      1. Note: You should see output from ssh-add indicating it added the keys in the ~/.ssh directory. If not, it may have been already added.
    10. ssh-add -L
      1. Note: Verify you have the key you just created added.
    11. In an editor like Notepad, open the .PUB file and copy the text into the clipboard.
    12. In a browser, log into github.com (or create an account).
    13. In Github.com, to the the upper-right corner, and click on the icon for the user, and then settings in the pulldown.
      1. Add a key. See https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/ for more info.
    14. Back in the Cygwin Terminal started in step 1 …
    15. ssh -v git@github.com
      • When it prompts for “do you want to continue?”, enter yes.
      • The output should look like this:

 

$ ssh -v git@github.com
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Connecting to github.com [192.30.252.129] port 22.
debug1: Connection established.
debug1: identity file /home/Ken/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/Ken/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/Ken/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.252.129]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi kaby76! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 3388, received 1796 bytes, in 0.1 seconds
Bytes per second: sent 42231.9, received 22387.4
debug1: Exit status 1
      1. git clone git@github.com:heroku/ruby-rails-sample.git
        1. Note: This verifies that command-line Git works. If it doesn’t then you should probably use ssh-pageant because git is not using the right agent.
      2. Note: If you use SourceTree (or other Git clients), verify they work too. This is because they use a damn separate authentication tool: pageant.exe. You can tell if you see in the lower-right corner the Pageant server icon.
      3. Find the Pageant server, and open it
      4. 2016-02-18 (4)
      5. In SourceTree, go to menu item “Tools | Create or Import SSH Keys”.
      6. In the dialog box, click on “Load” button, and find the file id_rsa (or the file name you entered above). You will have to type it in explicitly, or remove the stupid filter for the open file dialog box. Save the key, both public and private (generates a PPK file that’s compatible with Pageant).
      7. In Pageant, “Add Key”, using the .PPK generated above by SourceTree utility.
      8. Execute plink.exe in the Atlassian/SourceTree installation directory from Cygwin Terminal or Cmd.
      9. plink git@github.com
      10. In SourceTree, In SourceTree, clone the above Ruby sample. If it hangs, use plink.exe from the Cygwin Terminal.
$ plink git@github.com
Hi kaby76! You've successfully authenticated, but GitHub does not provide shell access.
Using username "git".
Server refused to allocate pty

Additional Information