3

I have (finally) got sshd working under cygwin on Win7 - well, sort of.

The sshd runs as user 'cyg_server'. I'm able to successfully ssh to my computer using that same user name.

However, if I attempt to ssh using my normal (Windows) user name, it fails trying to allocate a pty for my login session. For example, output of 'sshd -D -d -d -d' contains this

debug1: Entering interactive session for SSH2.
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: server_init_dispatch_20
debug1: server_input_channel_open: ctype session rchan 0 win 1048576 max 16384
debug1: input_session_request
debug1: channel 0: new [server-session]
debug2: session_new: allocate (allocated 0 max 10)
debug3: session_unused: session id 0 unused
debug1: session_new: session 0
debug1: session_open: channel 0
debug1: session_open: session 0: link with channel 0
debug1: server_input_channel_open: confirm session
debug1: server_input_global_request: rtype no-more-sessions@openssh.com want_reply 0
debug1: server_input_channel_req: channel 0 request pty-req reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req pty-req
debug1: Allocating pty.
debug1: session_pty_req: session 0 alloc /dev/pty1

!!! chown(/dev/pty1, 17308, 10513) failed: Invalid argument

debug1: do_cleanup
debug1: session_pty_cleanup: session 0 release /dev/pty1

Currently /dev is owned by my normal account. I've tried changing its ownership to cyg_server as well as SYSTEM. In both cases the problem persists. I've also changed permissions for /dev (e.g, 700 and 777) - again problem persists.

[As a side note - it is strange that whenever I do 'ls -al /dev' the ptys do not show up. However, if I 'ls -l /dev/ptyX' for a pty I know to exist, it shows up. Is that normal for cygwin?]

Wesley
  • 32,690
  • 9
  • 82
  • 117
Paperclip Bob
  • 131
  • 1
  • 3

2 Answers2

1

Deleting all the /etc/ssh* files and re-running ssh-host-config in a cygwin window opened as administrator fixed the problem for me, I assume by correcting permissions.

I had to do a fair amount of checking and correcting before I was able to get this working:

  • The /etc/ssh* key files are owned, readable and writable by the privileged server account (eg cyg_server)
  • /dev is owner by my (administrator) user account and rwxable by administrators, users and sshd's user
  • The service has been restarted
  • You have set the environment variables CYGWIN=ntsec
Dylan Lacey
  • 111
  • 2
1

I had an odd issue after cloning the original Windows VM by doing a 'sysprep' initially -
" that changes the SID of the machine=>SID of all local users, but /etc/password is of course unchanged. That resulted in pubkey authorization failing with "sshd: fatal: chown(/dev/pty1) failed: Permission denied" messages in Win' Application Event log.

TL;DR Running the Cygwin console elevated (as Administrator), net stop sshd, doing a 'mkpasswd -l' and replacing all local accounts info in /etc/passwd from it's output, then deleting /etc/ssh*, ssh-host-config, net start sshd was the fix for me.

Chris S
  • 77,945
  • 11
  • 124
  • 216
user221326
  • 11
  • 2