PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.44k stars 762 forks source link

sshd is working for clients but not for sftp #1489

Closed mcajkovs closed 4 years ago

mcajkovs commented 5 years ago

My OS is windows 10 Home and I've successfully set up sshd server for clients but not for sftp.

I've followed this wiki to set up SSH server https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH

Steps I've taken:

  1. downloaded latest release https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.0.0.0p1-Beta/OpenSSH-Win64.zip and extracted it in c:\Program Files\OpenSSH
  2. next steps were preformed either in admin mode cmd.exe or admin mode powershell.exe
PS C:\Program Files\OpenSSH> Get-Service ssh*

Status   Name               DisplayName
------   ----               -----------
Stopped  SshdBroker         SshdBroker

PS C:\Program Files\OpenSSH> netstat -ano | findstr :22
  TCP    192.168.195.1:64929    192.168.195.130:22     ESTABLISHED     22508

CMD c:\Program Files\OpenSSH>powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
[SC] SetServiceObjectSecurity SUCCESS
[SC] ChangeServiceConfig2 SUCCESS
[SC] ChangeServiceConfig2 SUCCESS
sshd and ssh-agent services successfully installed

PS C:\Program Files\OpenSSH> Remove-NetFirewallRule -DisplayName 'OpenSSH Server (sshd)'
PS C:\Program Files\OpenSSH> New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
PS C:\Program Files\OpenSSH> netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
CMD c:\Program Files\OpenSSH>rm -rfd %programdata%\ssh

PS C:\Program Files\OpenSSH> net start sshd
The OpenSSH SSH Server service is starting..
The OpenSSH SSH Server service was started successfully.
  1. added following lines to %programdata%\ssh\sshd_config

    SyslogFacility LOCAL0
    LogLevel DEBUG3
    Subsystem   sftp    C:/Program Files/OpenSSH/sftp-server.exe
  2. restarted ssh

    PS C:\Program Files\OpenSSH> net stop sshd
    PS C:\Program Files\OpenSSH> net start sshd
  3. connect from another machine (in my case guest virtual linux) via ssh -vvv 'marek'@192.168.195.1 works but sftp (also winscp) fails:

> sftp -vvv 'marek'@192.168.195.1
debug3: authmethod_lookup password
debug3: remaining preferred:
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
marek@192.168.195.1's password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 52
debug1: Authentication succeeded (password).
Authenticated to 192.168.195.1 ([192.168.195.1]:22).
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug3: Ignored env LS_COLORS
debug3: Ignored env STY
debug3: Ignored env SSH_CONNECTION
debug3: Ignored env LESSCLOSE
debug1: Sending env LANG = en_US.UTF-8
debug2: channel 0: request env confirm 0
debug3: send packet: type 98
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env USER
debug3: Ignored env PWD
debug3: Ignored env HOME
debug3: Ignored env WINDOW
debug3: Ignored env SSH_CLIENT
debug3: Ignored env XDG_DATA_DIRS
debug3: Ignored env SSH_TTY
debug3: Ignored env MAIL
debug3: Ignored env SHELL
debug3: Ignored env TERM
debug3: Ignored env SHLVL
debug3: Ignored env LOGNAME
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env PATH
debug3: Ignored env TERMCAP
debug3: Ignored env LESSOPEN
debug3: Ignored env _
debug1: Sending subsystem: sftp
debug2: channel 0: request subsystem confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: subsystem request accepted on channel 0
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Transferred: sent 2328, received 2460 bytes, in 0.4 seconds
Bytes per second: sent 5869.8, received 6202.6
debug1: Exit status 1
Connection closed

server logs:

2472 2019-10-30 02:16:45.942 debug1: session_close_by_channel: channel 0 child 0
2472 2019-10-30 02:16:45.942 Close session: user marek from 192.168.195.130 port 51390 id 0
2472 2019-10-30 02:16:45.942 debug3: session_unused: session id 0 unused
2472 2019-10-30 02:16:45.942 debug2: channel 0: gc: user detached
2472 2019-10-30 02:16:45.942 debug2: channel 0: is dead
2472 2019-10-30 02:16:45.942 debug2: channel 0: garbage collecting
2472 2019-10-30 02:16:45.942 debug1: channel 0: free: server-session, nchannels 1
2472 2019-10-30 02:16:45.942 debug3: channel 0: status: The following connections are open:\r\n  #0 server-session (t4 r0 i3/0 o3/0 e[closed]/0 fd -1/-1/-1 sock -1 cc -1)\r\n
2472 2019-10-30 02:16:45.943 debug3: receive packet: type 1
2472 2019-10-30 02:16:45.943 Received disconnect from 192.168.195.130 port 51390:11: disconnected by user
2472 2019-10-30 02:16:45.943 Disconnected from 192.168.195.130 port 51390
2472 2019-10-30 02:16:45.943 debug1: do_cleanup
20012 2019-10-30 02:16:45.945 debug3: mm_request_receive entering
20012 2019-10-30 02:16:45.945 debug1: do_cleanup
maertendMSFT commented 4 years ago

Can you try the newest version? Please open a new issue if this persists and provide the sshd log and sftp-server log