<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Shannon Cornish &#187; ssh</title>
	<atom:link href="http://www.shannoncornish.com/blog/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shannoncornish.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 26 Jul 2010 09:22:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up a Git server with Windows Server 2008</title>
		<link>http://www.shannoncornish.com/blog/2009/04/git-server-windows-2008/</link>
		<comments>http://www.shannoncornish.com/blog/2009/04/git-server-windows-2008/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 05:55:15 +0000</pubDate>
		<dc:creator>Shannon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.shannoncornish.com/blog/?p=88</guid>
		<description><![CDATA[I&#8217;m in the middle of setting up a Git server at work and needed to document the process that I used for installation, setup and administration. I figured the best place to put the documentation was to blog about it so that others might benefit and improve it. The server operating system we&#8217;re running is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the middle of setting up a <a href="http://git-scm.com/">Git</a> server at work and needed to document the process that I used for installation, setup and administration. I figured the best place to put the documentation was to blog about it so that others might benefit and improve it.</p>
<p>The server operating system we&#8217;re running is Windows Server 2008.</p>
<h3>What is Git?</h3>
<p>Git is a distributed version control system originally developed by Linus Torvalds to manage the Linux kernel.</p>
<p>Git is available on Windows using <a href="http://cygwin.com">Cygwin</a> or <a href="http://code.google.com/p/msysgit/">msysGit</a>.</p>
<p>
For the server installation, I&#8217;ve chosen to use the Cygwin version of Git. We will be using a SSH server for our server to authenticate users and allow access to the repositories. Using Cygwin will allow us to use the Cygwin version OpenSSH for our server.</p>
<h3>Installing Cygwin</h3>
<ul>
<li>Create the C:\Cygwin directory.</li>
<li>Create the C:\Cygwin\packages directory.</li>
<li>Modify the permissions on the C:\Cygwin directory to grant the USERS group modify permissions.</li>
<li>Download the Cygwin setup package into the C:\Cygwin directory and run the setup.</li>
<li>Use the following options for the Cygwin setup package:
<ul>
<li>Choose Installation Type
<ul>
<li>Leave default Install from Internet</li>
</ul>
</li>
<li>Choose Installation Directory
<ul>
<li>Leave default root directory C:\Cygwin</li>
<li>Leave default install for All Users</li>
<li>Leave default text file type Unix/binary</li>
</ul>
</li>
<li>Select Local Packages Directory
<ul>
<li>Change local packages directory to C:\Cygwin\packages</li>
</ul>
</li>
<li>Select Connection Type
<ul>
<li>Leave default direct connection</li>
</ul>
</li>
<li>Choose Download Site(s)
<ul>
<li>Add a local <a href="http://cygwin.com/mirrors.html">mirror</a></li>
</ul>
</li>
<li>Select Packages
<ul>
<li>Select Devel &gt; git</li>
<li>Select Devel &gt; git-completion</li>
<li>Select Devel &gt; git-gui</li>
<li>Select Devel &gt; gitk</li>
<li>Select Net &gt; openssh</li>
<li>Select Python &gt; python</li>
</ul>
</li>
<li>Installation Status and Create Icons
<ul>
<li>Leave default create icon on Desktop</li>
<li>Leave default Add icon to Start Menu</li>
</ul>
</li>
</ul>
</li>
<li> Modify the C:\Cygwin\cygwin.bat file to set the CYGWIN environment variable. The whole file should appear as follows:
<pre>@echo off
set CYGWIN=binmode tty ntsec

c:
chdir c:\cygwin\bin

bash --login -i</pre>
</li>
<li>
Run Cygwin from the desktop. It should display:</p>
<pre>Copying skeleton files.
These files are for the user to personalise
their cygwin experience.

These will never be overwritten.

'./.bashrc' -&gt; '/home/Administrator//.bashrc'
'./.bash_profile' -&gt; '/home/Administrator//.bash_profile'
'./.inputrc' -&gt; '/home/Administrator//.inputrc'</pre>
</li>
<li>
Execute</p>
<pre>
mount -s --change-cygdrive-prefix /
</pre>
</li>
<li>
Execute</p>
<pre>
mkdir -p /home
</pre>
</li>
<li>
Execute</p>
<pre>
chmod +r //etc//passwd
chmod +r //etc//group
chmod 755 //var
</pre>
<p>Note: The above statements should use a single slash rather than a double slash. The double slash is required to work around the filter from my blogging software.
</li>
<li>Close the Cygwin bash prompt</li>
</ul>
<h3>Installing OpenSSH</h3>
<ul>
<li>Open the Cygwin bash prompt as an Administrator via right clicking and selecting Run as administrator.</li>
<li>Execute
<pre>ssh-host-config</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Creating default /etc/ssh_config file
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep.
*** Query: Should privilege separation be used? (yes/no)
</pre>
</li>
<li>
Type</p>
<pre>
yes
</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Note that creating a new user requires that the current account have
*** Info: Administrator privileges.  Should this script attempt to create a
*** Query: new local account 'sshd'? (yes/no)
</pre>
</li>
<li>
Type</p>
<pre>
yes
</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Updating /etc/sshd_config file

*** Warning: The following functions require administrator privileges!

*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no)
</pre>
</li>
<li>
Type</p>
<pre>
yes
</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Note that the CYGWIN variable must contain at least "ntsec"
*** Info: for sshd to be able to change user context without password.
*** Query: Enter the value of CYGWIN for the daemon: [ntsec]
</pre>
</li>
<li>
Type</p>
<pre>
binmode tty ntsec
</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.

*** Info: You appear to be running Windows 2003 Server or later.  On 2003
*** Info: and later systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.

*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.

*** Info: No privileged account could be found.

*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no)
</pre>
</li>
<li>
Type</p>
<pre>
no
</pre>
</li>
<li>
You should see</p>
<pre>
*** Query: Create new privileged user account 'cyg_server'? (yes/no)
</pre>
</li>
<li>
Type</p>
<pre>
yes
</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Please enter a password for new user cyg_server.  Please be sure
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.
*** Query: Please enter the password:
</pre>
</li>
<li>Type and confirm a password for the new &#8216;cyg_server&#8217; account.</li>
<li>After confirming the password, you should see
<pre>
*** Info: User 'cyg_server' has been created with password 'azxggsri7#35z'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'cyg_server' account.

*** Info: Also keep in mind that the user 'cyg_server' needs read permissions
*** Info: on all users' relevant files for the services running as 'cyg_server'.

*** Info: In particular, for the sshd server all users' .ssh/authorized_keys
*** Info: files must have appropriate permissions to allow public key
*** Info: authentication. (Re-)running ssh-user-config for each user will set
*** Info: these permissions corrently. [Similary restrictions apply, for
*** Info: instance, for .rhosts files if the rshd server is running, etc].

*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account.  To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
*** Info: after the next reboot.

*** Info: Host configuration finished. Have fun!
</pre>
</li>
<li>
Execute</p>
<pre>net start sshd</pre>
</li>
<li>Open the Windows Firewall Editor and create an exception to allow TCP traffic on port 22.
</ul>
<h3>Creating a Git user account for SSH access</h3>
<p>
Single SSH account will run under.
</p>
<ul>
<li>Create a &#8216;git&#8217; account via the standard windows tools and make sure to disable password expiry.<br />
The account should be a member of the USERS group.</li>
<li>Open the Cygwin bash prompt and type
<pre>mkpasswd -l -u git -p //home >> //etc//passwd</pre>
<p>Note: The above statements should use a single slash rather than a double slash. The double slash is required to work around the filter from my blogging software.
</li>
<li>Log out of the Administrator account and login as the git account.</li>
<li>
Run Cygwin from the desktop. It should display:</p>
<pre>Copying skeleton files.
These files are for the user to personalise
their cygwin experience.

These will never be overwritten.

'./.bashrc' -&gt; '/home/git//.bashrc'
'./.bash_profile' -&gt; '/home/git//.bash_profile'
'./.inputrc' -&gt; '/home/git//.inputrc'</pre>
</li>
<li>
Execute</p>
<pre>ssh-user-config</pre>
</li>
<li>You should see
<pre>
*** Warning: group and other have been revoked write permission to your home
*** Warning: directory /home/git.
*** Warning: This is required by OpenSSH to allow public key authentication using
*** Warning: the key files stored in your .ssh subdirectory.
*** Warning: Revert this change ONLY if you know what you are doing!

*** Query: Shall I create an SSH1 RSA identity file for you? (yes/no)
</pre>
</li>
<li>Type
<pre>no</pre>
</li>
<li>
You should see</p>
<pre>*** Query: Shall I create an SSH2 RSA identity file for you? (yes/no)</pre>
</li>
<li>
Type</p>
<pre>yes</pre>
</li>
<li>
You should see</p>
<pre>
*** Info: Generating /home/git/.ssh/id_rsa
Enter passphrase (empty for no passphrase):
</pre>
</li>
<li>Press enter to create with an empty passphrase and press enter again to confirm.</li>
<li>You should see
<pre>
*** Query: Do you want to use this identity to login to this machine? (yes/no)
</pre>
</li>
<li>Type
<pre>yes</pre>
</li>
<li>You should see
<pre>
*** Info: Adding to /home/git/.ssh/authorized_keys
*** Query: Shall I create an SSH2 DSA identity file for you? (yes/no)
</pre>
</li>
<li>Type
<pre>no</pre>
</li>
<li>
You should see</p>
<pre>*** Info: Configuration finished. Have fun!</pre>
</li>
</ul>
<p>We have now configured our Windows Server 2008 machine with Git and an account to use with SSH access. In the next blog post, I&#8217;ll cover installation and configuration of <a href="http://eagain.net/gitweb/?p=gitosis.git">Gitosis</a> to secure access and authentication of repositories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shannoncornish.com/blog/2009/04/git-server-windows-2008/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
