You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Next »

Gather Required Files & Information

You will need the following:

  • VMware Server RPM installation file
  • VMWare Server serial number
  • Windows XP installation ISO file
  • Windows XP product key

The following instructions assume the following locations on the management node:

  • VMWare Server RPM: /install/VMware-server-1.0.8-126538.i386.rpm
  • Windows XP ISO: /install/WinXP+SP3.iso

Install VMWare Server

  1. Establish root access: sudo bash
  2. Install the VMWare Server RPM:
    rpm -ivh  /install/VMware-server-1.0.8-126538.i386.rpm
    
  3. Run the following command to configure VMWare Server:
    vmware-config.pl
    

Create a Virtual Machine

  1. Launch the VMWare Server console:
    vmware-server-console &
    
  2. Connect to Local Host
  3. Copy a Windows XP ISO image to the VMWare Server machine 
  4. Create a new VM
    1. Type: Typical
    2.  Guest OS: Microsoft Windows, Version: Windows XP Professional
    3. Name: Windows XP Base
    4. Network connection: Use bridged networking
    5. Disk size: 8.0 GB
      1. Allocate all disk space now: no
      2. Split disk into 2GB files: yes
  5. Edit virtual machine settings
    1. Select the CD-ROM
    2. Connection: Use ISO image: browse to path of Windows XP ISO image file: /install/WinXP+SP3.iso

Install Windows XP on the Virtual Machine 

  1. Power on the the VM
  2. Press ESC as soon as VM begins to start to display the boot menu
    • Boot from the CD-ROM drive
  3. Press a key to boot from the CD (if displayed at bottom of screen as soon as VM begins to boot)
  4. Proceed through Windows XP installation
    1. Press Enter to setup up Windows XP now 
    2. Press F8 to agree to the license agreement 
    3. Configure the Windows partition 
      1. Press Enter to set up Windows XP on the selected item (should be called "Unpartitioned space")
      2.  Format the partition using the NTFS file system (Quick)
    4. Enter a name and organization 
    5. Enter the Windows XP product key 
    6. Enter a computer name and password
    7. Select a timezone
    8. Networking settings: Typical
    9. Member of a domain: No, leave default workgroup settings
    10. Do not turn on automatic updates
    11. Enter "root" as the user name

Configure the Windows XP Virtual Machine 

  1. Run Microsoft Update 
  2. Configure the root user account
    1. Set root's password: either the user management GUI or execute the following command:
      net user root <PASSWORD>
      
    2. Make sure root is a member of the Administrators group using the user management GUI or execute the following command:
      net localgroup Administrators root /ADD
      
  3. Install VMWare Tools
    1. Click on the VM menu and select "Install VMWare Tools"
    2. Select Typical
    3. Reboot the VM

Install Cygwin 

  1. Download and run the Cygwin installer: http://cygwin.com/setup.exe
    • Install from Internet
    • Root Directory: C:\Cygwin
    • Install For: Just Me
    • Default Test File Type: DOS/text
    • Local Package Directory: *C:*
    • Internet Connection: Direct Connection
    • Download Site: choose one (.edu FTP sites seem the fastest)
    • Select Packages: Net: openssh
    • Create icon on Desktop: No
    • Add icon to Start Menu: No
  2. Delete the local package directory: C:\ftp%...cygwin...

Configure Cygwin SSH service

  1. Copy the cygwin-sshd-config.sh script (contents below) to the C:\Cygwin\home\root directory on the Windows VM
  2. Set the script to be executable:
    chmod +x /home/root/cygwin-sshd-config.sh
    
  3. Launch C:\Cygwin\Cygwin.bat
  4. Run the script and specify the root account password as an argument, enclose the password in ticks in case special characters are used in the password:
    /home/root/cygwin-sshd-config.sh '<PASSWORD>'
    
    Note: the sshd service probably will not start until the next step is completed
  5. Open Start -> Run -> services.msc
  6. Double-click the Cygwin sshd service
  7. Open the Log On tab
  8. Enter the root account password twice and click OK, you should see a message stating root has been granted the Log On As A Service Right
  9. Click the General tab
  10. Click Start

Create an SSH key pair on the Management Node and Copy the Public Key to the authorized_keys File on the Windows XP VM

  1. Copy the gen-node-key.sh script (contents below) to the /root directory on the management node
  2. Set the script to be executable:
    chmod +x /root/gen-node-key.sh
    
  3. Run the script and specify the node as an argument (either the node's DNS name or IP address can be used):
    /root/gen-node-key.sh 192.168.22.55
    
  4. Attempt to connect from the management node to the Windows VM via SSH using the key:
    ssh -i /etc/vcl/vcl.key 192.168.22.55
    

Shell script to configure the Cygwin SSHD service, to be run on Windows XP computer:

cygwin-sshd-config.sh

if [ $# -ne 1 ]
then
  echo "Usage: $0 '<root password>'"
  exit 1
fi
PASSWORD=$1

echo Stopping sshd service if it is running
net stop sshd 2>/dev/null
echo ----------

echo Deleting sshd service if it already exists
$SYSTEMROOT/system32/sc.exe delete sshd
echo ----------

echo Deleting the sshd user if it already exists
net user sshd /DELETE
echo ----------

echo Deleting '/etc/ssh*'
rm -fv /etc/ssh*
echo ----------

echo Deleting /var/log/sshd.log if it exists
rm -fv /var/log/sshd.log
echo ----------

echo Setting root:Administrators as owner of '/etc' and '/var'
chown -R root:Administrators /etc /var
echo ----------

echo Adding ug+rwx permissions to '/etc' and '/var'
chmod -v ug+rwx /etc /var
echo ----------

echo Adding read permission on /etc/passwd and /etc/group
chmod -v +r /etc/passwd /etc/group
echo ----------

echo Adding ug+w permission on /etc/passwd and /etc/group
chmod -v ug+w /etc/passwd /etc/group
echo ----------

echo Recreating /etc/group
mkgroup -l > /etc/group
echo ----------

echo Recreating /etc/passwd
mkpasswd -l > /etc/passwd
echo ----------

echo Configuring mount points
umount -u /usr/bin 2>/dev/nul
mount -f -s -b C:/cygwin/bin /usr/bin
umount -u /usr/lib 2>/dev/nul
mount -f -s -b C:/cygwin/lib /usr/lib
umount -u / 2>/dev/nul
mount -f -s -b C:/cygwin /
echo ----------

echo Adding execute permission on /var
chmod -v +x /var
echo ----------

echo Running ssh-host-config
ssh-host-config -y
echo ----------

echo Creating /var/empty directory if it does not exist
mkdir /var/empty 2>/dev/NULL
echo ----------

echo Setting root:Administrators as owner of /var/empty
chown -Rv root:Administrators /var/empty
echo ----------

echo Setting permissions to 755 on /var/empty
chmod -Rv 755 /var/empty
echo ----------

echo Setting permissions to 775 on /var/log
chmod -Rv 775 /var/log
echo ----------

echo Creating /var/log/sshd.log file if it does not exist
touch /var/log/sshd.log
echo ----------

echo Setting root:Administrators as owner of '/etc/ssh*' and /var/log/sshd.log
chown -Rv root:Administrators /etc/ssh* /var/log/sshd.log
echo ----------

echo Setting permissions to ug+rw on '/etc/ssh*' and /var/log/sshd.log
chmod -Rv ug+rw /etc/ssh* /var/log/sshd.log
echo ----------

echo Setting permissions to 600 on '/etc/ssh*key'
chmod -v 600 /etc/ssh*key
echo ----------

echo Setting permissions to ug+rwx on /etc
chmod -v ug+rwx /etc
echo ----------

echo Configuring /etc/sshd_config
echo LogLevel VERBOSE
sed -i -r -e "s/.?(LogLevel).*/\1 VERBOSE/" /etc/sshd_config
echo PermitRootLogin yes
sed -i -r -e "s/.?(PermitRootLogin).*/\1 yes/" /etc/sshd_config
echo MaxAuthTries 15
sed -i -r -e "s/.?(MaxAuthTries).*/\1 15/" /etc/sshd_config
echo PasswordAuthentication yes
sed -i -r -e "s/.?(PasswordAuthentication).*/\1 yes/" /etc/sshd_config
echo Banner none
sed -i -r -e "s/.?(Banner).*/\1 none/" /etc/sshd_config
echo UsePrivilegeSeparation yes
sed -i -r -e "s/.?(UsePrivilegeSeparation).*/\1 yes/" /etc/sshd_config
echo StrictModes no
sed -i -r -e "s/.?(StrictModes).*/\1 no/" /etc/sshd_config
echo ----------

echo Configuring the sshd service to log to /var/log/sshd.log
reg.exe ADD "HKLM\SYSTEM\CurrentControlSet\Services\sshd\Parameters" /v AppArgs /d "-D -e" /t REG_SZ /f
echo ----------

echo Configuring the sshd service to use the root account: $PASSWORD
$SYSTEMROOT/system32/sc.exe config sshd obj= ".\root" password= "$PASSWORD"
echo ----------

echo Configuring firewall port 22 exception
netsh firewall set portopening name = "Cygwin SSHD" protocol = TCP port = 22 mode = ENABLE profile = ALL scope = ALL
echo ----------

echo Starting the sshd service
net start sshd
echo ----------

echo /var/log/sshd.log ending:
tail -n 10 /var/log/sshd.log
echo ----------

echo Done

 

----Shell script to create an SSH key pair on the management node and copy it to the authorized_keys file on a node:

gen-node-key.sh

if [ $# -ne 1 ]
then
  echo "Usage: $0 <node>"
  exit 1
fi
NODE=$1

echo Creating /home/root/.ssh directory on $NODE
ssh -o BatchMode=no $NODE 'mkdir /home/root/.ssh'
echo ----------

echo Creating SSH keys on management node: '/etc/vcl/vcl.key(.pub)'
ssh-keygen -t rsa -f /etc/vcl/vcl.key -N '' -b 1024 -C 'root on VCL management node'
echo ----------

echo Copying public key to authorized_keys on $NODE
scp -o BatchMode=no /etc/vcl/vcl.key.pub $NODE:/home/root/.ssh/authorized_keys
echo ----------

echo Setting PermitRootLogin to no in sshd_config on $NODE
ssh -i /etc/vcl/vcl.key root@$NODE 'sed -i -r -e "s/.?(PermitRootLogin).*/\1 no/" /etc/sshd_config'
ssh -i /etc/vcl/vcl.key root@$NODE 'grep PermitRootLogin /etc/sshd_config'
echo ----------

echo Setting PasswordAuthentication to no in sshd_config on $NODE
ssh -i /etc/vcl/vcl.key root@$NODE 'sed -i -r -e "s/.?(PasswordAuthentication).*/\1 no/" /etc/sshd_config'
ssh -i /etc/vcl/vcl.key root@$NODE 'grep PasswordAuthentication /etc/sshd_config'
echo ----------

echo Done
  • No labels