Friday, June 5, 2009

Configure Cygwin sshd for Build Automation

Our build is initiated from a UNIX build server, then invokes the Windows build portion.

1. create a local build user on the Windows build server. Use the same id as in the UNIX server. Password can be different.

2. install cygwin on the Windows build server.

3. set up sshd service.
There is a very nice article about how to set up sshd using cygwin, including which cygwin packages to install, how to install and configure ssh service, how to generate user pulib/private keys, and how to add the user to the password file.
In summary, use the following command.
ssh-host-config
ssh-user-config
You should be able to find a "CYGWIN sshd" service in Windows machine. Make sure the service is started.

4. in the ssh client (UNIX build server), login as build id, generate rsa (or dsa) public/private keys. entry cartridge return (empty) for passphrase.
# ssh-keygen -t dsa
public key is save to ~/.ssh/id_dsa.pub
private key is saved to ~/.ssh/id_dsa

5. sftp the public key(id_dsa.pub) to ~/.ssh directory on the ssh SERVER (Windows build server).

6. create an authorization file in the ~/.ssh directory on SERVER, add the public key in.

server> cat /id_dsa.pub >> /.ssh/authorized_keys
7. To verify that you can connect to the target system, log in through from the client. An entry will be created in the ~/.ssh/known_hosts file in the server.
$ ssh id@target
Now you can integrate the Windows build with UNIX build process.

...
ssh -n -o NumberOfPasswordPrompts=0 ccadmin@winbuild "rm -rf /cygdrive/e/CBFE_Build/${RELEASE}"
ssh ccadmin@winbuild "cd /cygdrive/e/CBFE_Build/${RELEASE}; /usr/bin/unzip -u /cygdrive/e/CBFE_Build/${FILENAME}"
ssh ccadmin@winbuild "cd /cygdrive/e;/cygdrive/c/Program\ Files/InstallShield/2009/System/IsCmdBld.exe -p CBFE_Build/IS_Projects/${RELEASE}/CBFE_Common/CBFE_Common.ism -z BUILD_VERSION=${BUILD_LABEL}"
....

No comments: