Problems with cygwin, "expect" and ssh
I have found some interesting behavior regarding the cygwin expect/ssh problem. I used the little expect script That Corinna created. It seemed to not see the prompt for the password from the spawned ssh, so it just timed out. But, when I redirect the stderr to /dev/null, it behaves correctly. Perhaps ssh is spitting some spurious bytes to stderr that are causing the expect pattern to not match: GOOD: [EMAIL PROTECTED] ~ $ ./sshtest 2>/dev/null spawn ssh -t 10.65.16.41 Before expect for assword: [EMAIL PROTECTED]'s password: Found assword: Before send of password After send of password Last login: Thu Jan 01 1970 00:00:00 from [==] Use of this system is explicitly limited to employees... - BAD: [EMAIL PROTECTED] ~ $ ./sshtest spawn ssh -t Before expect for assword: [EMAIL PROTECTED]'s password: Spawning failed [EMAIL PROTECTED] ~ --- SCRIPT: cat sshtest #!/usr/bin/expect -f set timeout 10 spawn ssh -t puts "Before expect for assword:" expect { "*assword:" { puts "Found assword:" sleep 2 } default { send_user "Spawning failed\n" exit } } puts "Before send of password" send "xxx\r" puts "After send of password" expect { -re ".*\\$.* " { } default { send_user "Sending password failed\n" exit } } send "ls\n" expect { -re ".*\\$.* " { } default { send_user "Sending ls failed\n" exit } } send "exit\n" expect { -re ".*Connection to mycygwinbox closed.*" { } default { send_user "Sending exit failed\n" exit } } -- 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/
Re: Problems with cygwin, "expect" and ssh
On Mon, Oct 13, 2003 at 06:47:12PM -0500, Greenup, Greenup wrote: >Enter "expect", which ships with a little script for changing your > password (even on multiple systems en-mass). Nice. Except... it doesn't > seem to work with ssh... Near as I can tell from my googling, a problem of > openssh reading the tty directly, rather than allocating a tty. True? > False? What about other things?; messing with the CYGWIN variable, adding > "tty" in there was not helpful, nor was adding "-t" to ssh. Any other > ideas? I don't want to use telnet... "console telnet" is nice, and will get > the job done, but it's not a secure answer. I'm not sure what you did wrong but apparently you did. I just tried the following crude script: = SNIP = #!/usr/bin/expect -f set timeout 10 spawn ssh mycygwinbox expect { "[EMAIL PROTECTED]'s password: " { } default { send_user "Spawning failed\n" exit } } send "mypassword\n" expect { -re ".*\\$.* " { } default { send_user "Sending password failed\n" exit } } send "ls\n" expect { -re ".*\\$.* " { } default { send_user "Sending ls failed\n" exit } } send "exit\n" expect { -re ".*Connection to mycygwinbox closed.*" { } default { send_user "Sending exit failed\n" exit } } = SNAP = and it worked perfectly fine, from a Windows console window as well as from a ssh session itself. The first two regexps are expecting my prompt, btw. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developermailto:[EMAIL PROTECTED] Red Hat, Inc. -- 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/
Problems with cygwin, "expect" and ssh
I've done a fair bit of searching on the net (6+hours of googling), but can't find a solution, or a complete "No, there's no way to work around that" to this problem: I have to log into a large number of systems, and on some sets (such as "all devboxes") I like to keep my password the same, for convenience. (and to keep my memory sane; I really need to keep this list from going "hundreds") Ssh is my tool of preference, though I could use telnet. Unfortunately, the Higher Powers have declared private key authentication illegal so far (I'm working on them), so I am left with typing this stuff by hand. All of that, I can more or less deal with, until *Password*Day*. Remember "hundreds"? Obviously, I don't log into all of these boxes during a given month, but I really have to be able to get to them when the time comes. Enter "expect", which ships with a little script for changing your password (even on multiple systems en-mass). Nice. Except... it doesn't seem to work with ssh... Near as I can tell from my googling, a problem of openssh reading the tty directly, rather than allocating a tty. True? False? What about other things?; messing with the CYGWIN variable, adding "tty" in there was not helpful, nor was adding "-t" to ssh. Any other ideas? I don't want to use telnet... "console telnet" is nice, and will get the job done, but it's not a secure answer. -greenup -- 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/