This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: automate SSH-HOST-CONFIG


Hi Dimitri, thanks for your help.

I created the script based on yours but it never sends the expect back to
the program.

#!/bin/bash
#!./expect -f 
chmod +r /etc/passwd
chmod +r /etc/group
chmod +x /var

echo "Starting Script"

ssh-host-config 
# Host keys generation is lengthy procedure
set timeout 20

expect {
  "*** Query: Overwrite existing /etc/ssh_config file? (yes/no)" { send
"yes\r";
exp_continue }
  "Overwrite existing /etc/sshd_config file? (yes/no)" { send "yes\r";
exp_continue }
  "Should privilege separation be used? (yes/no)" { send "yes\r" 
exp_continue}
  "Say "no" if it is already installed as a service) (yes/no)" { send
"yes\r"
exp_continue}
  "Enter the value of CYGWIN for the daemon: [ntsec]" { send "\r"
exp_continue}
  "Do you want to use a different name? (yes/no) " { send  "no\r"
exp_continue}
  "Please enter the password for user 'cyg_server':" { send "password\r"
exp_continue}
  "Reenter: " { send "password" }
} 

echo "end First Part"
set timeout 5 

expect {
  "Should this script create a local user 'sshd' on this machine?
(yes/no)" { send "yes\r" }
  "new local account 'sshd'? (yes/no)" { send "yes\r" }
}

I took out the exec so I could see the script run and it simply hangs at the
first query where it asks to overwrite existing files. Is there anything
else I need to do to get this to work with cygwin?




Dmitry Semyonov-2 wrote:
> 
> Hi Johnny,
> 
> On Tue, Jan 13, 2009 at 03:28, blazt wrote:
>>
>> I am not sure how to do a except script. I have been looking at what I
>> can
>> find on the net.
> 
> It is 'expect', not 'except'. It's enough to read 'man expect' for basics.
> You'll have to learn some Tcl docs for advanced usage, (not required
> for ssh-host-config automation).
> 
> 
>> Would I pass this command into the except part?
> 
> See an excerpt from my expect script below. I don't provide the full
> version, as it is complicated more than necessary for the
> demonstration due to support of different OSes and corner cases. (Also
> it was not verified with the latest ssh-host-config.)
> 
> 
> #!/bin/expect -f
> 
> # required on Win2k3
> exec chmod +r /etc/passwd
> exec chmod +r /etc/group
> exec chmod +x /var
> 
> spawn ssh-host-config
> 
> # Host keys generation is lengthy procedure
> set timeout 20
> 
> expect {
>   "Overwrite existing /etc/ssh_config file? (yes/no)" { send "yes\r";
> exp_continue }
>   "Overwrite existing /etc/sshd_config file? (yes/no)" { send "yes\r";
> exp_continue }
>   "Should privilege separation be used? (yes/no)" { send "yes\r" }
> }
> 
> set timeout 5
> 
> expect {
>   "Should this script create a local user 'sshd' on this machine?
> (yes/no)" { send "yes\r" }
>   "new local account 'sshd'? (yes/no)" { send "yes\r" }
> }
> 
> # [skipped]
> 
> expect eof { exec cygrunsrv -S sshd }
> 
> 
> -- 
> ...Bye..Dmitry.
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/automate-SSH-HOST-CONFIG-tp21383170p21442493.html
Sent from the Cygwin list mailing list archive at Nabble.com.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]