After upgrading my Cygwin packages recently (running cygwin-1.5.18-1), I found that I could no longer log in to a variety of Linux servers running various versions of sshd from OpenSSH (OpenSSH_3.5p1 on Red Hat 9, OpenSSH_3.8.1p1 on Debian 3.1, OpenSSH_4.1p1 on Debian post-3.1-unstable). Here's the output I'm getting from "ssh -v hostname" (replaced real hostname with "hostname"; replaced real IP address with "1.2.3.4"; replaced real home directory with "~"):
$ ssh -v hostname OpenSSH_4.1p1, OpenSSL 0.9.8 05 Jul 2005 debug1: Connecting to hostname [1.2.3.4] port 22. debug1: Connection established. debug1: identity file ~/.ssh/identity type -1 debug1: identity file ~/.ssh/id_rsa type 1 debug1: identity file ~/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_3.8.1p1 Debian-8.sarge.4 debug1: match: OpenSSH_3.8.1p1 Debian-8.sarge.4 pat OpenSSH_3.* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 none debug1: kex: client->server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'hostname' is known and matches the RSA host key. debug1: Found key in ~/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS Write failed: No such file or directory After some debugging, I found out that the error message after "Write failed:" is simply the last errno entry populated in the course of running ssh (in this case ENOENT), and doesn't actually represent the error that is occurring. I also discovered two distinct ways to fix this problem: 1. Configure openssh with the '--with-cflags="-DPACKET_DEBUG=1"' switch, then build openssh. This prevents the bug from occurring at the cost of copious debugging output of packet information. The fact that this works would indicate to me that there is some kind of compiler (code generation) issue or that some kind of race condition exists that is related to the network layer. 2. Apply the attached patch and (re)build openssh. After reading the manpage for write(2), it said that write(2) returns -1 on error, thus errno will not contain a "related" error if checked when write(2) returns 0. (There were other mitigating circumstances when writing to "real" files according to the manpage, but this did not apply.) The fact that this patch works tells me that write(2) seems to be broken, and is actually returning 0 when it should be returning a positive integer (e.g., the value of "len" in this case). Note that I tried running "ssh.exe" from openssh-3.9p1-3/cygwin-1.5.13-1 with cygwin-1.5.18-1, and it had the exact same problem. (I have not tried compiling openssh-4.1p1-2 on the system running cygwin-1.5.13-1 yet, though.) Any idea what's going on? Dave
openssh-4.1p1-2-cygwin-fix-write-failed.diff
Description: openssh-4.1p1-2-cygwin-fix-write-failed.diff
-- 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/