ssh-host-config Vista and --yes do not run unattended

Ben Smith le.ben.smith@gmail.com
Mon Dec 7 21:28:00 GMT 2009


I've been working on an unattended cygwin/sshd install.  On Vista, the
ssh-host-config script waits for user input at several points when the
"--yes" option is used.  The "--yes" option is usually there to allow
for unattended use of a script, and this behavior breaks the ability
to use the script unattended.

I've fixed this by modifying openssh-5.1p1-10 and csih-0.2.0-1.

To reproduce:

1) Install cygwin with the openssh package on Vista.
2) Run ssh-host-config --yes.

Result:

ssh-host-config stops and waits for user input.

The first problem happens in cygwin-service-installation-
helper.sh.  The script asks a question about creating a special user
"cyg_server" for running sshd under.  The question is worded so that
"no" is the default answer.  This means that if you run
ssh-host-config with "--yes" on Vista, the question is answered "yes"
and the script pauses, waiting for input.

Other problems arise because mv commands stop and ask the user for
permission to overwrite files.

I am attaching patches against ssh-host-config and
cygwin-service-installation-helper.sh.  With these changes,
ssh-host-config can be run unattended on Vista.

I hardcoded a password into ssh-host-config because the -w option to
ssh-host-config doesn't seem to create the same kind of user.  It
would probably be better to modify ssh-host-config so that the -w
option works with the Vista user creation.

--Ben Smith


*** new/ssh-host-config    2009-12-07 13:54:26.000000000 -0700
--- usr/bin/ssh-host-config    2008-11-20 11:18:43.000000000 -0700
***************
*** 26,32 ****
  privsep_configured=no
  privsep_used=yes
  cygwin_value="ntsec"
! password_value="asecretpassword"

  # ======================================================================
  # Routine: create_host_keys
--- 26,32 ----
  privsep_configured=no
  privsep_used=yes
  cygwin_value="ntsec"
! password_value=

  # ======================================================================
  # Routine: create_host_keys
***************
*** 87,93 ****
      grep -v 'sshd[ \t][ \t]*22' "${_services}" > "${_serv_tmp}"
      if [ -f "${_serv_tmp}" ]
      then
!       if mv -f "${_serv_tmp}" "${_services}"
        then
          csih_inform "Removing sshd from ${_wservices}"
        else
--- 87,93 ----
      grep -v 'sshd[ \t][ \t]*22' "${_services}" > "${_serv_tmp}"
      if [ -f "${_serv_tmp}" ]
      then
!       if mv "${_serv_tmp}" "${_services}"
        then
          csih_inform "Removing sshd from ${_wservices}"
        else
***************
*** 104,110 ****
    then
      if awk '{ if ( $2 ~ /^23\/tcp/ ) print "ssh
22/tcp'"${_spaces}"'SSH Remote Login Protocol\nssh
22/udp'"${_spaces}"'SSH Remote Login Protocol"; print $0; }' <
"${_services}" > "${_serv_tmp}"
      then
!       if mv -f "${_serv_tmp}" "${_services}"
        then
          csih_inform "Added ssh to ${_wservices}"
        else
--- 104,110 ----
    then
      if awk '{ if ( $2 ~ /^23\/tcp/ ) print "ssh
22/tcp'"${_spaces}"'SSH Remote Login Protocol\nssh
22/udp'"${_spaces}"'SSH Remote Login Protocol"; print $0; }' <
"${_services}" > "${_serv_tmp}"
      then
!       if mv "${_serv_tmp}" "${_services}"
        then
          csih_inform "Added ssh to ${_wservices}"
        else
***************
*** 163,169 ****
          s/^#StrictModes yes/StrictModes no/" \
          < ${SYSCONFDIR}/sshd_config \
          > "${sshdconfig_tmp}"
!     mv -f "${sshdconfig_tmp}" ${SYSCONFDIR}/sshd_config
    elif [ "${privsep_configured}" != "yes" ]
    then
      echo >> ${SYSCONFDIR}/sshd_config
--- 163,169 ----
          s/^#StrictModes yes/StrictModes no/" \
          < ${SYSCONFDIR}/sshd_config \
          > "${sshdconfig_tmp}"
!     mv "${sshdconfig_tmp}" ${SYSCONFDIR}/sshd_config
    elif [ "${privsep_configured}" != "yes" ]
    then
      echo >> ${SYSCONFDIR}/sshd_config
***************
*** 196,202 ****
          grep -v '^[# \t]*ssh' "${_inetcnf}" >> "${_inetcnf_tmp}"
          if [ -f "${_inetcnf_tmp}" ]
          then
!           if mv -f "${_inetcnf_tmp}" "${_inetcnf}"
            then
            csih_inform "Removed ssh[d] from ${_inetcnf}"
            else
--- 196,202 ----
          grep -v '^[# \t]*ssh' "${_inetcnf}" >> "${_inetcnf_tmp}"
          if [ -f "${_inetcnf_tmp}" ]
          then
!           if mv "${_inetcnf_tmp}" "${_inetcnf}"
            then
            csih_inform "Removed ssh[d] from ${_inetcnf}"
            else
***************
*** 218,224 ****
        else
          sed -e 's/@COMMENT@[ \t]*/# /' < "${_sshd_inetd_conf}" >
"${_sshd_inetd_conf_tmp}"
        fi
!       mv -f "${_sshd_inetd_conf_tmp}" "${_sshd_inetd_conf}"
        csih_inform "Updated ${_sshd_inetd_conf}"
      fi

--- 218,224 ----
        else
          sed -e 's/@COMMENT@[ \t]*/# /' < "${_sshd_inetd_conf}" >
"${_sshd_inetd_conf_tmp}"
        fi
!       mv "${_sshd_inetd_conf_tmp}" "${_sshd_inetd_conf}"
        csih_inform "Updated ${_sshd_inetd_conf}"
      fi

***************
*** 233,239 ****
        grep -v '^[# \t]*sshd' "${_inetcnf}" >> "${_inetcnf_tmp}"
        if [ -f "${_inetcnf_tmp}" ]
        then
!         if mv -f "${_inetcnf_tmp}" "${_inetcnf}"
          then
          csih_inform "Removed sshd from ${_inetcnf}"
          else
--- 233,239 ----
        grep -v '^[# \t]*sshd' "${_inetcnf}" >> "${_inetcnf_tmp}"
        if [ -f "${_inetcnf_tmp}" ]
        then
!         if mv "${_inetcnf_tmp}" "${_inetcnf}"
          then
          csih_inform "Removed sshd from ${_inetcnf}"
          else



*** new/cygwin-service-installation-helper.sh    2009-12-07
14:09:14.000000000 -0700
--- usr/share/csih/cygwin-service-installation-helper.sh    2009-05-03
18:18:38.000000000 -0700
***************
*** 2414,2420 ****
        csih_inform "'${username}' will only be used by registered services."
        if [ $opt_force -eq 0 ]
        then
!         if ! csih_request "Do you want to use that name?"
          then
            csih_get_value "Enter the new user name:"
            username="${csih_value}"
--- 2414,2420 ----
        csih_inform "'${username}' will only be used by registered services."
        if [ $opt_force -eq 0 ]
        then
!         if csih_request "Do you want to use a different name?"
          then
            csih_get_value "Enter the new user name:"
            username="${csih_value}"

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list