diff -ur /ssh-2.0.13/apps/ssh/ssh-add2.c ssh-2.0.13/apps/ssh/ssh-add2.c
--- /ssh-2.0.13/apps/ssh/ssh-add2.c	Tue May 11 12:35:29 1999
+++ ssh-2.0.13/apps/ssh/ssh-add2.c	Tue Aug 03 07:10:53 1999
@@ -59,7 +59,7 @@
   LIST, 
   ADD, 
   ADD_URL,
-  DELETE,
+  DELETE_,
   DELETE_URL,
   DELETE_ALL, 
   LOCK, 
@@ -156,7 +156,7 @@
     
       if (action == ADD)
         printf("Adding identity: %s\n", pubname);
-      else if (action == DELETE)
+      else if (action == DELETE_)
         printf("Deleting identity: %s\n", pubname);
     
       if (stat(pubname, &st) < 0)
@@ -290,7 +290,7 @@
                           agent_completion, (void *)agent);
           ssh_private_key_free(key);
         }
-      else if (action == DELETE)
+      else if (action == DELETE_)
         {
           ssh_agent_delete(agent, certs, certs_len, saved_comment,
                            agent_completion, (void *)agent);
@@ -484,7 +484,7 @@
           ssh_private_key_free(key);
           return;
         }
-      else if (action == DELETE)
+      else if (action == DELETE_)
         {
           ssh_agent_delete(agent, 
                            public_blob, 
@@ -685,7 +685,7 @@
       ssh_agent_unlock(agent, password, agent_completion, (void *)agent);
       break;
 
-    case DELETE:
+    case DELETE_:
     case DELETE_URL:
     case ADD:
     case ADD_URL:
@@ -785,7 +785,7 @@
           if (action == ADD_URL)
             action = DELETE_URL;
           else
-            action = DELETE;
+            action = DELETE_;
           break;
 
         case 'D':
@@ -829,7 +829,7 @@
           break;
 
         case 'u':
-          if (action == DELETE)
+          if (action == DELETE_)
             action = DELETE_URL;
           else
             action = ADD_URL;
diff -ur /ssh-2.0.13/apps/ssh/sshauthmethods.c ssh-2.0.13/apps/ssh/sshauthmethods.c
--- /ssh-2.0.13/apps/ssh/sshauthmethods.c	Fri Apr 09 11:30:12 1999
+++ ssh-2.0.13/apps/ssh/sshauthmethods.c	Tue Aug 03 05:54:05 1999
@@ -25,9 +25,13 @@
 
 static SshAuthServerMethod server_methods[] =
 {
+#ifndef __CYGWIN__
   { SSH_AUTH_PUBKEY, ssh_server_auth_pubkey },
+#endif
   { SSH_AUTH_PASSWD, ssh_server_auth_passwd },
+#ifndef __CYGWIN__
   { SSH_AUTH_HOSTBASED, ssh_server_auth_hostbased },
+#endif
   { NULL, NULL }
 };
 
diff -ur /ssh-2.0.13/apps/ssh/sshchsession.c ssh-2.0.13/apps/ssh/sshchsession.c
--- /ssh-2.0.13/apps/ssh/sshchsession.c	Fri May 07 15:02:03 1999
+++ ssh-2.0.13/apps/ssh/sshchsession.c	Tue Aug 03 05:54:06 1999
@@ -23,6 +23,7 @@
 #include "sshmsgs.h"
 #include "sshcommon.h"
 #include "sshuserfiles.h"
+#include "sshuser.h"
 
 #ifdef SSH_CHANNEL_SESSION
 
@@ -64,12 +65,16 @@
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #else /* Some old linux systems at least have in_system.h instead. */
+#ifndef __CYGWIN__
 #include <netinet/in_system.h>
+#endif /* __CYGWIN__ */
 #endif /* HAVE_NETINET_IN_SYSTM_H */
 #if !defined(__PARAGON__)
 #include <netinet/ip.h>
 #endif /* !__PARAGON__ */
+#ifndef __CYGWIN__
 #include <netinet/tcp.h>
+#endif /* __CYGWIN__ */
 #include <arpa/inet.h>
 #include <netdb.h>
 #ifdef HAVE_SYS_SELECT_H
@@ -667,6 +672,7 @@
       chdir("/");
     }
   
+#ifndef __CYGWIN__
   /* Create empty environment. */
   envsize = 10;
   env = ssh_xmalloc(envsize * sizeof(env[0]));
@@ -679,6 +685,9 @@
   /* Export the environment to commands run in the remaining initialization
      (e.g. xauth). */
   environ = env;
+#else
+  env = environ;
+#endif
 
 #ifdef HAVE_SIA
   /* Now that the user's environment has been initialized and before
@@ -711,7 +720,11 @@
       for (i = 0; env[i]; i++)
         ssh_debug("  %.200s", env[i]);
 
+#ifndef __CYGWIN__
       execve(shell, argv, env);
+#else
+      sexecve(hToken,shell, argv, env);
+#endif
       perror(shell);
       exit(254);      
     }
@@ -798,8 +811,12 @@
               }
           }        
       }
-      
+
+#ifndef __CYGWIN__      
       execve(shell, argv, env);
+#else
+      sexecve(hToken,shell, argv, env);
+#endif
       /* Executing the shell failed. */
       perror(shell);
       exit(254);
@@ -809,7 +826,11 @@
       argv[1] = "-c";
       argv[2] = (char *)command;
       argv[3] = NULL;
+#ifndef __CYGWIN__
       execve(shell, argv, env);
+#else
+      sexecve(hToken,shell, argv, env);
+#endif
       perror(shell);
       exit(254);
 
@@ -825,7 +846,11 @@
               argv[1] = "-c";
               argv[2] = session->common->config->subsystems[i]->path;
               argv[3] = NULL;
+#ifndef __CYGWIN__
               execve(shell, argv, env);
+#else
+	      sexecve(hToken,shell, argv, env);
+#endif
               perror(shell);
               exit(254);
             }       
diff -ur /ssh-2.0.13/apps/ssh/sshchx11.c ssh-2.0.13/apps/ssh/sshchx11.c
--- /ssh-2.0.13/apps/ssh/sshchx11.c	Wed Apr 28 07:47:16 1999
+++ ssh-2.0.13/apps/ssh/sshchx11.c	Tue Aug 03 05:54:06 1999
@@ -37,12 +37,16 @@
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #else /* Some old linux systems at least have in_system.h instead. */
+#ifndef __CYGWIN__
 #include <netinet/in_system.h>
+#endif /* __CYGWIN__ */
 #endif /* HAVE_NETINET_IN_SYSTM_H */
 #if !defined(__PARAGON__)
 #include <netinet/ip.h>
 #endif /* !__PARAGON__ */
+#ifndef __CYGWIN__
 #include <netinet/tcp.h>
+#endif /* __CYGWIN__ */
 #include <arpa/inet.h>
 #include <netdb.h>
 #ifdef HAVE_SYS_SELECT_H
diff -ur /ssh-2.0.13/configure ssh-2.0.13/configure
--- /ssh-2.0.13/configure	Tue May 11 12:34:58 1999
+++ ssh-2.0.13/configure	Tue Aug 03 05:54:26 1999
@@ -7066,7 +7066,7 @@
   pty="getpseudotty"
   echo "$ac_t""getpseudotty" 1>&6
 else
-if test -c /dev/ptmx && test -c /dev/pts/0
+if test -c /dev/ptmx
 then
   pty="ptmx"
   echo "$ac_t""streams ptys" 1>&6
diff -ur /ssh-2.0.13/configure.in ssh-2.0.13/configure.in
--- /ssh-2.0.13/configure.in	Tue May 11 12:34:37 1999
+++ ssh-2.0.13/configure.in	Tue May 11 12:33:33 1999
@@ -1051,7 +1051,7 @@
   pty="getpseudotty"
   AC_MSG_RESULT(getpseudotty)
 else
-if test -c /dev/ptmx && test -c /dev/pts/0
+if test -c /dev/ptmx
 then
   pty="ptmx"
   AC_MSG_RESULT(streams ptys)
diff -ur /ssh-2.0.13/lib/sshapputil/sshuserfile.c ssh-2.0.13/lib/sshapputil/sshuserfile.c
--- /ssh-2.0.13/lib/sshapputil/sshuserfile.c	Tue May 11 12:35:20 1999
+++ ssh-2.0.13/lib/sshapputil/sshuserfile.c	Tue Aug 03 05:54:08 1999
@@ -179,6 +179,9 @@
 #define USERFILE_GET_DES_1_MAGIC_PHRASE        29
 #define USERFILE_GET_DES_1_MAGIC_PHRASE_REPLY  30
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
 
 /* Flag indicating whether we have forked. */
 static int ssh_userfile_initialized = 0;
@@ -407,7 +410,7 @@
           flags = buffer_get_int(&packet);
           mode = buffer_get_int(&packet);
 
-          ret = open(path, flags, mode);
+          ret = open(path, flags | O_BINARY, mode);
 
           ssh_userfile_packet_start(USERFILE_OPEN_REPLY);
           buffer_put_int(&packet, ret);
@@ -764,7 +767,7 @@
 
   if (uid == geteuid())
     {
-      handle = open(path, flags, mode);
+      handle = open(path, flags | O_BINARY, mode);
       if (handle < 0)
         return NULL;
       return ssh_userfile_make_handle(USERFILE_LOCAL, handle);
diff -ur /ssh-2.0.13/lib/sshsession/pty-ptmx.c ssh-2.0.13/lib/sshsession/pty-ptmx.c
--- /ssh-2.0.13/lib/sshsession/pty-ptmx.c	Tue May 11 12:21:29 1999
+++ ssh-2.0.13/lib/sshsession/pty-ptmx.c	Tue Aug 03 05:54:08 1999
@@ -19,7 +19,9 @@
 #include "sshsessionincludes.h"
 #include "pty-int.h"
 #include "sshunixptystream.h"
+#ifndef __CYGWIN__
 #include <stropts.h>
+#endif
 #ifdef HAVE_SYS_STREAM_H
 #include <sys/stream.h>
 #endif /* HAVE_SYS_STREAM_H */
@@ -70,6 +72,7 @@
       close(*ptyfd);
       return FALSE;
     }
+#ifndef __CYGWIN__
   /* Push the appropriate streams modules, as described in Solaris pts(7). */
   if (ioctl(*ttyfd, I_PUSH, "ptem") < 0)
     ssh_warning("ioctl I_PUSH ptem: %.100s", strerror(errno));
@@ -78,6 +81,7 @@
   /* HPUX does not have ttcompat, others need it.  Let's not give any
      warnings if this fails. */
   ioctl(*ttyfd, I_PUSH, "ttcompat");
+#endif
 
   return TRUE;
 }  
diff -ur /ssh-2.0.13/lib/sshsession/sshunixuser.c ssh-2.0.13/lib/sshsession/sshunixuser.c
--- /ssh-2.0.13/lib/sshsession/sshunixuser.c	Tue May 04 15:09:15 1999
+++ ssh-2.0.13/lib/sshsession/sshunixuser.c	Tue Aug 03 05:54:09 1999
@@ -54,6 +54,12 @@
 #include <usersec.h>
 #endif /* HAVE_USERSEC_H */
 
+#ifdef __CYGWIN32__
+#include <windows.h>
+HANDLE hToken = NULL;
+#endif
+
+
 #define SSH_DEBUG_MODULE "SshUnixUser"
 
 extern char *crypt(const char *key, const char *salt);
@@ -498,6 +504,15 @@
 {
   char *encrypted_password;
   const char *correct_passwd = uc->correct_encrypted_passwd;
+
+#ifdef __CYGWIN__
+  if (LogonUser(uc->name, NULL, password, LOGON32_LOGON_INTERACTIVE,
+				LOGON32_PROVIDER_DEFAULT, &hToken)
+      && SetHandleInformation (hToken, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
+    return TRUE;
+  else
+    return FALSE;
+#endif
 
 #ifdef HAVE_ULTRIX_SHADOW_PASSWORDS
   {
diff -ur /ssh-2.0.13/lib/sshsession/sshuser.h ssh-2.0.13/lib/sshsession/sshuser.h
--- /ssh-2.0.13/lib/sshsession/sshuser.h	Tue May 04 15:09:15 1999
+++ ssh-2.0.13/lib/sshsession/sshuser.h	Tue Aug 03 05:54:09 1999
@@ -16,6 +16,12 @@
 
 typedef struct SshUserRec *SshUser;
 
+#ifdef __CYGWIN32__
+#include <windows.h>
+extern HANDLE hToken;
+#endif
+
+
 /* Allocates and initializes a context for the user.  The context is used
    to cache information about the particular user.  Returns NULL if the
    user does not exist. If `user' is NULL, use getuid() to get the current
diff -ur /ssh-2.0.13/lib/sshsession/wtmp.c ssh-2.0.13/lib/sshsession/wtmp.c
--- /ssh-2.0.13/lib/sshsession/wtmp.c	Tue May 04 15:09:15 1999
+++ ssh-2.0.13/lib/sshsession/wtmp.c	Tue Aug 03 05:54:10 1999
@@ -48,6 +48,11 @@
 #endif /* HAVE_ARPA_INET_H */
 #include "sshuser.h"
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
 /* Internal function, defined in sshunixtcp.c */
 extern Boolean ssh_string_to_addr(const char *s, struct in_addr *addr);
 
@@ -83,7 +88,7 @@
 
   strcpy(hostbuf, "");
 
-  fd = open(lastlogfile, O_RDONLY);
+  fd = open(lastlogfile, O_RDONLY | O_BINARY);
   if (fd < 0)
     return 0;
   if (read(fd, &ll, sizeof(ll)) != sizeof(ll))
@@ -129,7 +134,7 @@
 
   strcpy(hostbuf, "");
 
-  fd = open(lastlog, O_RDONLY);
+  fd = open(lastlog, O_RDONLY | O_BINARY);
   if (fd < 0)
     return 0;
   lseek(fd, (off_t)((long)ssh_user_uid(user) * sizeof(ll)), 0);
@@ -248,8 +253,10 @@
     {
       struct in_addr sin_addr;
       /* if address is valid, put it in the struct. */
+#ifndef __CYGWIN__
       if(!inet_aton(ip, &sin_addr))
         memcpy(&u.ut_addr, &sin_addr, sizeof(u.ut_addr));
+#endif
     }
   else
     memset(&u.ut_addr, 0, sizeof(u.ut_addr));
@@ -272,7 +279,7 @@
   login(&u);
 #else /* HAVE_LIBUTIL_LOGIN */
   /* Append an entry to wtmp. */
-  fd = open(wtmp, O_WRONLY|O_APPEND);
+  fd = open(wtmp, O_WRONLY|O_APPEND|O_BINARY);
   if (fd >= 0)
     {
       if (write(fd, &u, sizeof(u)) != sizeof(u))
@@ -282,7 +289,7 @@
 
   /* Replace the proper entry in utmp, as identified by ut_line.  Append a
      new entry if the line could not be found. */
-  fd = open(utmp, O_RDWR);
+  fd = open(utmp, O_RDWR | O_BINARY);
   if (fd >= 0)
     {
 #ifdef HAVE_TTYSLOT
@@ -463,7 +470,7 @@
                "%.100s/%.100s", 
                lastlog,
                ssh_user_name(user));
-      fd = open(lastlogfile, O_WRONLY | O_CREAT, 0644);
+      fd = open(lastlogfile, O_WRONLY | O_CREAT | O_BINARY, 0644);
       if (fd >= 0)
         {
           if (write(fd, &ll, sizeof(ll)) != sizeof(ll))
@@ -477,7 +484,7 @@
                       lastlogfile, strerror(errno));
         }
 #else /* LASTLOG_IS_DIR */
-      fd = open(lastlog, O_RDWR);
+      fd = open(lastlog, O_RDWR | O_BINARY);
       if (fd >= 0)
         {
           lseek(fd, (off_t)((long)ssh_user_uid(user) * sizeof(ll)), 0);
diff -ur /ssh-2.0.13/lib/sshutil/sshfilexfers.c ssh-2.0.13/lib/sshutil/sshfilexfers.c
--- /ssh-2.0.13/lib/sshutil/sshfilexfers.c	Tue May 04 15:05:01 1999
+++ ssh-2.0.13/lib/sshutil/sshfilexfers.c	Tue Aug 03 05:54:10 1999
@@ -17,6 +17,10 @@
 #include "sshfilexfer.h"
 #include "sshfilexferi.h"
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 /* Data structure for a server-side file handle.  This definition is
    private to the implementation. */
 
@@ -309,7 +313,7 @@
         flags |= O_EXCL;
 
       /* Try to open the file. */
-      fd = open(name, flags,
+      fd = open(name, flags | O_BINARY,
                 (attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS) ?
                 attrs->permissions : 0666);
       
diff -ur /ssh-2.0.13/lib/sshutil/sshunixtcp.c ssh-2.0.13/lib/sshutil/sshunixtcp.c
--- /ssh-2.0.13/lib/sshutil/sshunixtcp.c	Tue May 11 12:35:13 1999
+++ ssh-2.0.13/lib/sshutil/sshunixtcp.c	Tue Aug 03 05:54:10 1999
@@ -30,12 +30,16 @@
 #ifdef HAVE_NETINET_IN_SYSTM_H
 #include <netinet/in_systm.h>
 #else /* Some old linux systems at least have in_system.h instead. */
+#ifndef __CYGWIN__
 #include <netinet/in_system.h>
+#endif /* __CYGWIN__ */
 #endif /* HAVE_NETINET_IN_SYSTM_H */
 #if !defined(__PARAGON__)
 #include <netinet/ip.h>
 #endif /* !__PARAGON__ */
+#ifndef __CYGWIN__
 #include <netinet/tcp.h>
+#endif /* __CYGWIN__ */
 #include <arpa/inet.h>
 #include <netdb.h>
 #ifdef HAVE_SYS_SELECT_H
@@ -710,7 +714,9 @@
   if (!se)
     return -1;
   port = ntohs(se->s_port);
+#ifndef __CYGWIN__
   endservent();
+#endif
   return port;
 #else  /* HAVE_GETSERVBYNAME */
   return -1;
@@ -734,7 +740,9 @@
     snprintf(buf, buflen, "%u", port);
   else
     strncpy(buf, se->s_name, buflen);
+#ifndef __CYGWIN__
   endservent();
+#endif
 #else /* HAVE_GETSERVBYPORT */
   snprintf(buf, buflen, "%u", port);
 #endif /* HAVE_GETSERVBYPORT */
