Porting openssh to Windows natively

jhui6124 at rogers.com jhui6124 at rogers.com
Thu Feb 3 09:23:35 EST 2011


Hi All,

I was assigned a project to port the openssh 5.4p1 to Windows.  There has been discussion about Cygwin and SUA on Windows, but the conclusion is to avoid a unix layer.  So came the project.  I was being assigned not because I am familir with openssh, but because I am a Windows application developer.  BTW, the objective is to have a windows sshd daemon, no client is needed at this stage.

To make it short, I have spent a couple of months working on this and at the present stage i can ssh from a unix box using SSH protocol 2 submitting commands, using password authentication.  What I am having trouble is the interactive sessions.  At first I thought the unix side is hung because nothing responds on my telnet terminal ( I am telnetting to the unix box, then test
the ssh connection from there).  However, after turning on the PACKET_DEBUG on my ssh server, I realize that every keystroke being pressed at the terminal was sent across the wire.  (Is this what is called by a raw mode?).  and the command was actually received by my WIndows SSHD.  And also, the "enter" keystroke was not recognised by the server as a command submission (CRLF).  I have to explicitly press Ctrl-J to submit the command.  Interesting enough, if I fool the unix ssh client by using "ssh username at hostname.com " "" (an empty command) to force the server side to go through the
do_exec_no_pty function, I can actually do what I want interactively if I keep the windows cmd.exe around without exiting.  Even the "enter" key and "local echo" is there.  Can anyone tell what is missing for my interactive session?  Ah, I have to back up a bit about what I did for the interactive session.  Since on windows, there is no concept of tty, instead of allocating a pty, I just created a sockpair to hook up the ptyfd and ttyfd when forking the child from do_exec_pty.  The ttyfd contains one of the socket of the socket pair, and the socket handle was passed  as the stdin/stdout/stderr of the windows cmd shell that is started by the child.  Could that be the reason?  Is the client always working on the raw mode?  Or it detected some setting being sent back from the server which put it into the raw mode?

As you can tell I am not a unix developer either.  Thanks for your patience and thanks for any advice in advance.

Jack


More information about the openssh-unix-dev mailing list