Friday, November 04, 2011

WAIK: Deploy WinPE via PXE

Additional configuration is required to make WinPE works well with PXE.

Prepare Boot Configuration file: BCD

Boot Configuration Data (BCD) contain information required by Windows boot kernel how to load Windows operating system.  The following batch script shows how to prepare a single BCD that may boot from 4 available WinPE images:

  1. vista_x86.wim
  2. vista_x64.wim
  3. win7_x86.wim
  4. win7_x64.wim

These files should be keep in TFTP’s folder: /windows_pe/

@echo off
Del BCD_PXE
bcdedit /createstore BCD_PXE

bcdedit /store BCD_PXE /create {ramdiskoptions}
bcdedit /store BCD_PXE /set {ramdiskoptions} ramdisksdidevice boot
bcdedit /store BCD_PXE /set {ramdiskoptions} ramdisksdipath \windows.pe\boot.sdi

bcdedit /store BCD_PXE /create {88C83FCF-809E-4B72-8921-D91E37DCD052} /application osloader /d "Windows Vista 32-bit PE"
bcdedit /store BCD_PXE /set {88C83FCF-809E-4B72-8921-D91E37DCD052} systemroot \Windows
bcdedit /store BCD_PXE /set {88C83FCF-809E-4B72-8921-D91E37DCD052} detecthal Yes
bcdedit /store BCD_PXE /set {88C83FCF-809E-4B72-8921-D91E37DCD052} winpe Yes
bcdedit /store BCD_PXE /set {88C83FCF-809E-4B72-8921-D91E37DCD052} osdevice ramdisk=[boot]\windows.pe\vista_x86.wim,{ramdiskoptions}
bcdedit /store BCD_PXE /set {88C83FCF-809E-4B72-8921-D91E37DCD052} device ramdisk=[boot]\windows.pe\vista_x86.wim,{ramdiskoptions}

bcdedit /store BCD_PXE /create {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} /application osloader /d "Windows Vista 64-bit PE"
bcdedit /store BCD_PXE /set {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} systemroot \Windows
bcdedit /store BCD_PXE /set {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} detecthal Yes
bcdedit /store BCD_PXE /set {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} winpe Yes
bcdedit /store BCD_PXE /set {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} osdevice ramdisk=[boot]\windows.pe\vista_x64.wim,{ramdiskoptions}
bcdedit /store BCD_PXE /set {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} device ramdisk=[boot]\windows.pe\vista_x64.wim,{ramdiskoptions}

bcdedit /store BCD_PXE /create {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} /application osloader /d "Windows 7 32-bit PE"
bcdedit /store BCD_PXE /set {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} systemroot \Windows
bcdedit /store BCD_PXE /set {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} detecthal Yes
bcdedit /store BCD_PXE /set {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} winpe Yes
bcdedit /store BCD_PXE /set {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} osdevice ramdisk=[boot]\windows.pe\win7_x86.wim,{ramdiskoptions}
bcdedit /store BCD_PXE /set {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} device ramdisk=[boot]\windows.pe\win7_x86.wim,{ramdiskoptions}

bcdedit /store BCD_PXE /create {0341BB74-EF1A-463C-8AFB-4025472EC7DB} /application osloader /d "Windows 7 64-bit PE"
bcdedit /store BCD_PXE /set {0341BB74-EF1A-463C-8AFB-4025472EC7DB} systemroot \Windows
bcdedit /store BCD_PXE /set {0341BB74-EF1A-463C-8AFB-4025472EC7DB} detecthal Yes
bcdedit /store BCD_PXE /set {0341BB74-EF1A-463C-8AFB-4025472EC7DB} winpe Yes
bcdedit /store BCD_PXE /set {0341BB74-EF1A-463C-8AFB-4025472EC7DB} osdevice ramdisk=[boot]\windows.pe\win7_x64.wim,{ramdiskoptions}
bcdedit /store BCD_PXE /set {0341BB74-EF1A-463C-8AFB-4025472EC7DB} device ramdisk=[boot]\windows.pe\win7_x64.wim,{ramdiskoptions}

bcdedit /store BCD_PXE /create {bootmgr}
bcdedit /store BCD_PXE /set {bootmgr} timeout 10
bcdedit /store BCD_PXE /displayorder {88C83FCF-809E-4B72-8921-D91E37DCD052} {7A213FBD-69BE-4B3F-B08C-B9A94CD929AC} {A5A5F300-04D4-4D98-9FD3-57E2E00E58D0} {0341BB74-EF1A-463C-8AFB-4025472EC7DB}
bcdedit /store BCD_PXE /default {0341BB74-EF1A-463C-8AFB-4025472EC7DB}

Execute the batch file should yield a new file: BCD_PXE.  We need this file in later stage

Files required by Windows PXE Boot Kernel

Windows PXE kernel requires the following files to boot WinPE properly:

# ls -l windows.pe
total 829716
-rwxr--r-- 1 root root     24576 Nov  3 16:55 BCD
-r-xr--r-- 1 root root    523328 Jul 14  2009 bootmgr.exe
-r-xr--r-- 1 root root   3170304 Jun 10  2009 boot.sdi
drwxr-xr-x 2 root root      4096 Nov  3 17:12 fonts
lrwxrwxrwx 1 root root        11 Nov  4 16:33 pxeboot.0 -> pxeboot.n12
-r-xr--r-- 1 root root     25772 Jun 11  2009 pxeboot.n12
-rwxr--r-- 1 root root 201179410 Nov  3 13:46 vista_x64.wim
-rwxr--r-- 1 root root 182745379 Jan 23  2008 vista_x86.wim
-r-xr--r-- 1 root root 168390841 Jul 14  2009 win7_re_x64.wim
-r-xr--r-- 1 root root 145287084 Nov 20  2010 win7_re_x86.wim
-rwxr--r-- 1 root root 148246498 Nov  3 18:04 win7_x64.wim

File: BCD

BCD file should configure via BCDEdit tool.  The above batch script generate a BCD file with file name BCD_PXE.  Rename it to BCD and keep in TFTP folder

File: bootmgr.exe, pxeboot.n12

Obtain from mounted WinPE image: <mount-dir>\Windows\Boot\PXE

File: boot.sdi

Obtain from mounted WinPE image: <mount-dir>\Windows\Boot\DVD\PCAT

Folder: fonts

Obtain from mounted WinPE image: <mount-dir>\Windows\Boot\Fonts

File: *.wim

WinPE images.  Prepared by WAIK tools.

Configure PXE Service

Windows PXE boot kernel file

The default Windows PXE boot kernel file has named as “pxeboot.n12”.  PXELinux requires Windows PXE boot kernel with suffix of .0 instead of .n12, use

# ln -s pxeboot.n12 pxeboot.0

PXE menus

Add a menu entry in pxelinux configuration that boot Windows PXE boot Kernel:

$ cat /var/lib/tftpboot/pxelinux.cfg/default
...
LABEL WINDOWS_PE
        menu label ^Windows Preinstallation Exnvironment
        kernel windows.pe/pxeboot.0
...

TFTP server file name remapping: /var/lib/tftpboot/rules

Windows PXE boot kernel requires files in specific location, use TFTP server file name remapping option to remap the file name to actual location.

Locate TFTP rules file:

# cat /etc/xinetd.d/tftp
service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -v -m /var/lib/tftpboot/rules -s /var/lib/tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

Enable remapping as follow:

$ cat /var/lib/tftpboot/rules
rg \\ /         # convert backslashes to slashes (useful for windows file names)
r ^bootmgr\.exe /windows.pe/bootmgr.exe
r ^/Boot /windows.pe

Try boot a bare bone machine with network PXE enabled and see if the Windows PXE kernel and WinPE files boot properly

Reference

  1. http://solitudo.net/blah/posts/Create_Windows_PE_rescue_and_installation_images_using_WAIK_for_Windows_7_and_configure_Linux_boot_server_for_PXE_booting_the_images/

WAIK: Create Windows Pre-installation Environment image

Windows Pre-installation Environment (WinPE) is a lightweight version of Windows XP, Windows Server 2003 or Windows Vista that is used for the deployment of workstations and servers. It is intended as a 32-bit or 64-bit replacement for MS-DOS during the installation phase of Windows, and can be booted via PXE, CD-ROM, USB flash drive or hard disk.

WinPE contains limited Windows API library that is enough for the installation of Windows operating system using familiar Windows GUI interface.

Windows Automated Installation Kit

Windows Automated Installation Kit (WAIK) is a free tool that may prepare a WinPE image.  It has a GUI tool – Windows System Image Manager that allow user create an answer for unattended installation.  Most usage of WAIK tools is via command line.  Installation of WAIK is easy and straight forward.

Prepare a plain WinPE image

WinPE image is a file with extension .wim.  In this example, we use a WAIK command line tools to create WinPE image.  There is a special console shell available in WAIK tools: “Deployment Tools Command Prompt

capture

To create a plain WinPE x86 image, simply run:

C:\>copype x86 c:\winpe_x86
A new WinPE image is created in the folder:
C:\>winpe_x86>dir
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86

11/04/2011  11:17 AM    <DIR>          .
11/04/2011  11:17 AM    <DIR>          ..
06/10/2009  02:14 PM             4,096 etfsboot.com
11/04/2011  11:17 AM    <DIR>          ISO
11/04/2011  11:17 AM    <DIR>          mount
07/13/2009  07:51 PM       114,088,185 winpe.wim
               2 File(s)    114,092,281 bytes
               4 Dir(s)  22,600,298,496 bytes free

The copype command support create x86, amd64 and ia64 WinPE image:

c:\>winpe_x86>copype
Usage: copype [x86 | amd64 | ia64] destination

Example: copype x86 c:\windowspe-x86

Mount and Un-mount a WinPE image

An administrator privilege access is required to mount a WinPE image.  Run “Deployment Tools Command Prompt” as administrator, and use imagex to mount the WinPE image:

C:\winpe_x86>imagex /mount winpe.wim 1 mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [C:\winpe_x86\winpe.wim, 1] -> [C:\winpe_x86\mount]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 8 sec

The contents in WinPE image looks like normal Windows installation:

C:\winpe_x86>dir mount
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\mount

11/04/2011  12:44 PM    <DIR>          .
11/04/2011  12:44 PM    <DIR>          ..
07/14/2009  10:04 AM    <DIR>          Program Files
07/14/2009  10:03 AM    <DIR>          Users
07/14/2009  10:51 AM    <DIR>          Windows
               0 File(s)              0 bytes
               5 Dir(s)  22,594,248,704 bytes free

To unmount the WinPE image, run

C:\winpe_x86>imagex /unmount mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Unmounting: [C:\winpe_x86\mount]...

[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 7 sec

Make changes to WinPE image

Follow the steps to make changes to WinPE image:

  1. Mount WinPE image using “/mountrw” switch
  2. Make necessary changes
  3. Unmount and commit changes using “/commit” switch

Prepare a WinPE image with Windows Recovery Environment

The plain WinPE image doesn’t contain Windows Recovery Environment (WinRE).  The WinPE with WinRE allows us to recover damage or corrupt Windows installation.  It is a handy environment for system administrator.

The windows installation DVD or ISO image file include Windows Recovery Environment WinPE image.  We may grep a ready WinPE image from it.

Locate a file install.wim under DVD:\\sources folder of installation tree:

C:\winpe_x86>dir d:\sources\install.wim
 Volume in drive D is GSP1RMCULFRER_EN_DVD
 Volume Serial Number is FE46-C76E

 Directory of d:\sources

04/12/2011  11:47 AM     2,249,015,826 install.wim
               1 File(s)  2,249,015,826 bytes
               0 Dir(s)               0 bytes free

Mount the install.wim in a new created folder os_install:

C:\winpe_x86>mkdir os_install
C:\winpe_x86>imagex /mount d:\sources\install.wim 1 os_install

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [d:\sources\install.wim, 1] -> [C:\winpe_x86\os_install]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 45 sec

Locate WinPE image of Windows Recovery Environment (WinRE.wim):

C:\winpe_x86>dir os_install\Windows\System32\Recovery
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\os_install\Windows\System32\Recovery

04/12/2011  10:17 AM    <DIR>          .
04/12/2011  10:17 AM    <DIR>          ..
06/11/2009  05:33 AM               660 ReAgent.xml
11/20/2010  11:09 PM       145,287,084 winRE.wim
               2 File(s)    145,287,744 bytes
               2 Dir(s)  22,371,160,064 bytes free

Copy WinRE.wim to serve as base WinPE image:

C:\winpe_x86>copy os_install\Windows\System32\Recovery\winRE.wim
        1 file(s) copied.

C:\winpe_x86>dir
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86

11/04/2011  02:28 PM    <DIR>          .
11/04/2011  02:28 PM    <DIR>          ..
06/10/2009  02:14 PM             4,096 etfsboot.com
11/04/2011  12:27 PM    <DIR>          ISO
11/04/2011  12:48 PM    <DIR>          mount
11/04/2011  02:22 PM    <DIR>          os_install
07/13/2009  07:51 PM       114,088,185 winpe.wim
11/20/2010  11:09 PM       145,287,084 winRE.wim
               3 File(s)    259,379,365 bytes
               5 Dir(s)  22,225,870,848 bytes free

Unmount os_install:

C:\winpe_x86>imagex /unmount os_install

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Unmounting: [C:\winpe_x86\os_install]...

[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 4 sec

Disable Windows Recovery Environment on start-up

WinRE.wim starts Windows Recovery Environment by default.  To disable it, make changes to “\windows\system32\winpeshl.ini” in WinRE.wim:

C:\winpe_x86>type mount\windows\System32\winpeshl.ini
[LaunchApp]
AppPath=X:\sources\recovery\recenv.exe

Make it start command prompt by default:

[LaunchApps]
%SYSTEMROOT%\System32\wpeinit.exe
%SYSTEMROOT%\System32\cmd.exe

You may manually execute

X:\>%SYSTEMDRIVE%\sources\recovery\recenv.exe

to run Windows Recovery Environment via command prompt:

Add drivers into WinPE image

Both the plain or WinRE WinPE image contain basic drivers that is just enough to boot up machine.  In network deployment environment, the network adapters is an important devices that should be configured once boot up with WinPE or else the subsequent network operation will fail.

Assume we have some drivers ready in folder c:\winpe_x86\drivers:

C:\winpe_x86>dir drivers
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\drivers

11/04/2011  02:45 PM    <DIR>          .
11/04/2011  02:45 PM    <DIR>          ..
11/04/2011  02:45 PM    <DIR>          Driver_Win7_7027_10202010
               0 File(s)              0 bytes
               3 Dir(s)  22,304,944,128 bytes free

Mount WinPE image as Read-Write mode:

C:\winpe_x86>imagex /mountrw winre.wim 1 mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [C:\winpe_x86\winre.wim, 1] -> [C:\winpe_x86\mount]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 8 sec

Use dism command to add a driver:

C:\winpe_x86>dism /image:c:\winpe_x86\mount /add-driver:C:\winpe_x86\drivers\Dri
ver_Win7_7027_10202010\Driver_Win7_7027_10202010\WIN7\32\rt86win7.inf

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Found 1 driver package(s) to install.
Installing 1 of 1 - C:\winpe_x86\drivers\Driver_Win7_7027_10202010\Driver_Win7_7
027_10202010\WIN7\32\rt86win7.inf: The driver package was successfully installed
.
The operation completed successfully.

Use “/recurse” switch to add all drivers at once:

C:\winpe_x86>dism /image:c:\winpe_x86\mount /add-driver:C:\winpe_x86\drivers /recurse

Unmount and commit WinPE image:

C:\winpe_x86>imagex /unmount /commit mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Committing: [C:\winpe_x86\mount]...

[ 100% ] Committing Image progress

Successfully committed image.

Unmounting: [C:\winpe_x86\mount]...


[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 13 sec

List available drivers in WinPE

C:\winpe_x86>dism /image:c:\winpe_x86\mount /get-drivers

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Obtaining list of 3rd party drivers from the driver store...

Driver packages listing:

Published Name : oem0.inf
Original File Name : rt86win7.inf
Inbox : No
Class Name : Net
Provider Name : Realtek
Date : 9/20/2010
Version : 7.27.920.2010

Published Name : oem1.inf
Original File Name : rt64win7.inf
Inbox : No
Class Name : Net
Provider Name : Realtek
Date : 9/20/2010
Version : 7.27.920.2010

Published Name : oem10.inf
Original File Name : ioatdma.inf
Inbox : No
Class Name : System
Provider Name : Intel
Date : 11/16/2009
Version : 1.3.22.0

Remove a driver in WinPE image

C:\winpe_x86\mount>dism /image:c:\winpe_x86\mount /Remove-Driver /Driver:C:\winp
e_x86\drivers\Driver_Win7_7027_10202010\Driver_Win7_7027_10202010\WIN7\32\rt86wi
n7.inf

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Found 1 driver package(s) to remove.
Removing 1 of 1 - oem0.inf: The driver package was successfully removed.
The operation completed successfully.

Create a WinPE Bootable CD-ROM

  1. CopyPE will create a folder ISO:
    c:\winpe_x64>dir
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64
    
    12/02/2011  09:23 AM    <DIR>          .
    12/02/2011  09:23 AM    <DIR>          ..
    07/13/2009  04:20 PM         1,474,560 efisys.bin
    07/13/2009  04:20 PM         1,474,560 efisys_noprompt.bin
    06/10/2009  02:14 PM             4,096 etfsboot.com
    12/02/2011  09:23 AM    <DIR>          ISO
    12/02/2011  09:23 AM    <DIR>          mount
    07/13/2009  08:13 PM       135,115,506 winpe.wim
                   4 File(s)    138,068,722 bytes
                   4 Dir(s)  26,488,061,952 bytes free
  2. Copy WinPE image file into ISO\sources.  Name the WinPE image file as boot.wim:
    c:\winpe_x64>copy c:\win7_x64.wim iso\sources\boot.wim
            1 file(s) copied.
    
    c:\winpe_x64>dir iso\sources
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64\iso\sources
    
    12/02/2011  09:50 AM    <DIR>          .
    12/02/2011  09:50 AM    <DIR>          ..
    11/29/2011  05:11 PM       185,913,458 boot.wim
                   1 File(s)    185,913,458 bytes
                   2 Dir(s)  26,302,144,512 bytes free
  3. Create ISO image:
    c:\winpe_x64>oscdimg -n –bc:\winpe_x64\etfsboot.com c:\winpe_x64\ISO winpe_x64.iso
    
    OSCDIMG 2.55 CD-ROM and DVD-ROM Premastering Utility
    Copyright (C) Microsoft, 1993-2007. All rights reserved.
    Licensed only for producing Microsoft authorized content.
    
    
    Scanning source tree
    Scanning source tree complete (21 files in 9 directories)
    
    Computing directory information complete
    
    Image file is 218308608 bytes
    
    Writing 21 files in 9 directories to winpe_x64.iso
    
    100% complete
    
    Final image file is 218308608 bytes
    
    Done.
    
    c:\winpe_x64>dir
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64
    
    12/02/2011  09:52 AM    <DIR>          .
    12/02/2011  09:52 AM    <DIR>          ..
    07/13/2009  04:20 PM         1,474,560 efisys.bin
    07/13/2009  04:20 PM         1,474,560 efisys_noprompt.bin
    06/10/2009  02:14 PM             4,096 etfsboot.com
    12/02/2011  09:23 AM    <DIR>          ISO
    12/02/2011  09:23 AM    <DIR>          mount
    07/13/2009  08:13 PM       135,115,506 winpe.wim
    12/02/2011  09:52 AM       218,308,608 winpe_x64.iso
                   5 File(s)    356,377,330 bytes
                   4 Dir(s)  26,083,835,904 bytes free
    
  4. The ISO file may burn into CD-ROM for booting.

Reference

  1. http://solitudo.net/blah/posts/Create_Windows_PE_rescue_and_installation_images_using_WAIK_for_Windows_7_and_configure_Linux_boot_server_for_PXE_booting_the_images/

Wednesday, July 20, 2011

Git: Using SmartGit in Windows

Windows users was addicted to GUI interface.  Command line git may be hard for users to get started with.  A nice Java based GIT GUI is available to fill the space.  SmartGit is there to help manage your Git repository using nice GUI frontend.  You may choose the portable SmartGit too in this case.

Work with SmartGit

SmartGit GUI frontend is easy to use.  Most of the common Git command is available in top buttons bar:

a_thumb[1]

To make SmartGit works, you should tell SmartGit where your Git executable is.  Navigate to Edit | Preferences…

b_thumb[1]

Using external file comparator

Smart support external file comparator by navigate to Edit | Preference | Tools | File Comparators:

i

Git SSH client

SmartGit provides two SSH client access: System SSH client or Smart SSH client:

j

SmartGit as SSH Client does not possess all SSH client option.  Using System SSH client with ssh.exe or putty plink.exe may enjoy most from SSH.

Git: using msysgit in Windows

Git was originally develop to manage Linux kernel source.  It is widely use in Linux community.  It has porting to many platform too including Windows.

msysgit is windows porting of Git.  It is git command line utility running in command shell console.  I personally prefer using portable msysgit and set path in my home user’s environment variable.  By using portable, I may switch git version easily when new release is available.  No setup and installation is needed for portable release.

First configuration task for msysgit is set path variable in your local user account’s environment variable to include the <msysgit>/bin folder.  Git will then available whenever you start cmd shell.

ssh.exe: Password authentication

The most common ssh authentication is password authentication.  The following example shows a basic usage to access git repository via SSH:

C:\> git clone ssh://alice@git.example.com/srv/repos/git/project.git project
Cloning into project...
<user>@<git-server>'s password:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

You should supply a user name (e.g: alice) for ssh connection or else it may fail.

ssh.exe: Password authentication without user name

There are situation with Git that user name may not supply in git command clause.  For example, a git repository that consist of submodule have .gitmodules as follow:

[submodule "build"]
    path = build
    url = ssh://git.example.com/srv/repos/git/build.git
[submodule "core"]
    path = core
    url = ssh://git.example.com/srv/repos/git/core.git

As the repository is shared for team work, commit .gitmodules with user name is not practical.  The git ssh clause should not contain user name in origin repository.  Nor it should be modified to add user name in local repository.  In this case, a default user name should supply with ssh access.

To automatically supply user name to git-server, create a ~/.ssh/config file with the following entry:

Host git.example.com
  User alice

Subsequent git operation accessing ssh will use the user specify in ~/.ssh/config. This is useful when the local user name is different to ssh service user name.

ssh.exe: public key authentication

To specify the private key used for public key authentication, update ~/.ssh/config as follow:

Host git.example.com
  IdentityFile ~/.ssh/id_dsa.home
  User alice

ssh.exe: public key authentication with key agent

If a private key was protected by passphrase, each git operation accessing ssh service with the private key requires user to enter passphrase.  This is some how troublesome and will cause problem for other program like smartgit that do not prompt for passphrase.

A direct solution is using ssh key agent: ssh-agent to supply private key to ssh.  For more detail information, please refer to this article: http://chee-yang.blogspot.com/2011/07/ssh-public-key-authentication.html

msysgit: public key authentication with Putty

First, follow instructions in this article: http://chee-yang.blogspot.com/2011/07/ssh-public-key-authentication-with.html to configure putty to work with ssh.

To make msysgit work with putty as ssh client, you need a putty program: plink.exe.  Download plink.exe and keep in save location as putty.exe.

Next, create a new environment variable GIT_SSH that point to plink.exe:

h

You may start using git that use putty as ssh client.

There are 2 types of ssh connection with plink: using SSH server name or putty saved session.

Plink with SSH server name is limited and does not make use of extra options available in putty.  A saved putty session may consume options like pageant authentication and SSH user name for authentication.  To make git work with putty saved session, just name saved session same as  SSH server name.

Error – missing libconv-2.dll

In PortableGit-1.7.6-preview20110709.7z release, you may encounter the following errors when executing some Git commands::

The program can’t start because libiconv-2.dll is missing from your computer. Try installing the program to fix this problem.

git-error

To get rid of the error, locate <msysgit>\bin\libconv-2.dll and copy to <msysgit>\libexec\git-core.