#!/bin/bash
# Title: Cygwin Setup For SSH
# Subject: Setup cygwin sshd for ssh key authentication
##############################
#
# Title: cygwin_sshd_Admin_setup.bash
#
# Date: 20011214
#
# Description:  
#  Initilize the host keys,
#  install cygwin sshd as service,
#  and setup keys, directories, permissions
#  for public key authentication
#
# By: john@stilen.com
#
##############################
#  After cygwin packages are installed,
#  start a bash shell, 
#
#  Find this script on the fie system,
#
#  Run it.  
#  See below for what it does.
#  It assumes a unix file system.
################################

# Iniitilize ssh1 & ssh2 keys on host
ssh-host-config -y

# Fix perms on host keys
chown system.system /etc/ssh_host*_key
chmod 600 /etc/ssh_host*_key

# Make Administrator keys with no passwds
# NOTE:  You can ssh to local host with putty,
#        As a better terminal emulator.
ssh-user-config -y -p ''

# Fix perms for public key authentication
# If these perms are not set, it will not work.
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys*

# Stop cygwin services named sshd
cygrunsrv -E sshd

# Remove cygwin services named sshd
cygrunsrv -R sshd

# Install cygwin Openssh3.0.1-p1 as service sshd    
cygrunsrv --install sshd \
	  --path /usr/sbin/sshd \
	  --args -D \

# Start the cygwin sshd service
cygrunsrv -S sshd
 
########################################
#
#  Found new setup
#
########################################
#   http://www.onlinemagic.com/~bgould/sshd.html
