0 votes
by (170 points)

I've hooked into the PreAuthentication & Authentication events and I'm simply accepting every request using e.Accept() and e.Accept(new FileServerUser(e.UserName, e.Password)) however the authentication fails; please see output from console logging below:-

2018-09-27 13:20:36.884 INFO --- press ctrl-c or ctrl-break to exit ---
2018-09-27 13:20:37.033 INFO FileServer(1)[3] Server: Starting server.
2018-09-27 13:20:37.040 INFO FileServer(1)[3] Server: Listening for connections at 0.0.0.0:22.
2018-09-27 13:20:37.040 INFO FileServer(1)[3] Server: Server started.
2018-09-27 13:20:38.090 DEBUG FileServer(1)[8] Server: Accepted connection from 127.0.0.1:5711.
2018-09-27 13:20:38.109 INFO FileServer(1)[8] Server: Session 1: Started on connection from 127.0.0.1:5711.
2018-09-27 13:20:38.113 DEBUG FileServer(1)[8] SSH: Session 1: Local SSH version: SSH-2.0-RebexSSH_1.0.6821.0
2018-09-27 13:20:38.121 DEBUG FileServer(1)[8] SSH: Session 1: Remote SSH version: SSH-2.0-WinSCP_release_5.13.4
2018-09-27 13:20:38.122 DEBUG FileServer(1)[8] SSH: Session 1: Performing algorithm negotiation and key exchange.
2018-09-27 13:20:38.155 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_KEXINIT (768 bytes).
2018-09-27 13:20:38.160 VERBOSE FileServer(1)[6] SSH: Session 1: Received packet SSH_MSG_KEXINIT (1104 bytes).
2018-09-27 13:20:38.177 DEBUG FileServer(1)[6] SSH: Session 1: Performing key exchange using diffie-hellman-group-exchange-sha256 with ssh-rsa.
2018-09-27 13:20:38.179 VERBOSE FileServer(1)[6] SSH: Session 1: Received packet SSH_MSG_PACKET34 (24 bytes).
2018-09-27 13:20:38.185 VERBOSE FileServer(1)[6] SSH: Session 1: Sent packet SSH_MSG_KEXDH_REPLY (1048 bytes).
2018-09-27 13:20:38.409 VERBOSE FileServer(1)[8] SSH: Session 1: Received packet SSH_MSG_PACKET32 (528 bytes).
2018-09-27 13:20:38.566 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_PACKET33 (832 bytes).
2018-09-27 13:20:38.572 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_NEWKEYS (16 bytes).
2018-09-27 13:20:38.600 DEBUG FileServer(1)[8] SSH: Session 1: Current encryptor is aes256-ctr/hmac-sha2-256.
2018-09-27 13:20:44.591 VERBOSE FileServer(1)[8] SSH: Session 1: Received packet SSH_MSG_NEWKEYS (16 bytes).
2018-09-27 13:20:44.592 DEBUG FileServer(1)[8] SSH: Session 1: Current decryptor is aes256-ctr/hmac-sha2-256.
2018-09-27 13:20:44.594 DEBUG FileServer(1)[8] SSH: Session 1: Key exchange finished.
2018-09-27 13:20:44.604 VERBOSE FileServer(1)[8] SSH: Session 1: Received packet SSH_MSG_SERVICE_REQUEST (64 bytes).
2018-09-27 13:20:44.605 DEBUG FileServer(1)[8] SSH: Session 1: Performing authentication.
2018-09-27 13:20:44.608 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_SERVICE_ACCEPT (64 bytes).
2018-09-27 13:20:47.857 VERBOSE FileServer(1)[8] SSH: Session 1: Received packet SSH_MSG_USERAUTH_REQUEST (80 bytes).
2018-09-27 13:20:47.863 DEBUG FileServer(1)[8] SSH: Session 1: Starting authentication as 'ddd' for 'ssh-connection'.
2018-09-27 13:20:47.870 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_USERAUTH_FAILURE (48 bytes).
2018-09-27 13:20:47.871 VERBOSE FileServer(1)[8] SSH: Session 1: Received packet SSH_MSG_DISCONNECT (112 bytes).
2018-09-27 13:20:47.873 VERBOSE FileServer(1)[8] SSH: Session 1: Sent packet SSH_MSG_DISCONNECT (96 bytes).
2018-09-27 13:20:47.875 INFO FileServer(1)[8] SSH: Session 1: Connection close requested.
2018-09-27 13:20:47.878 INFO FileServer(1)[8] Server: Session 1: Closed connection from 127.0.0.1:5711.

any help advice?

Applies to: Rebex SFTP

1 Answer

+1 vote
by (73.6k points)

You have to specify, which AuthenticationMethods are allowed. Please update your PreAuthentication handler to use:

e.Accept(AuthenticationMethods.Any);

If you want to execute sftp subsystem, you have to specify root directory for the user. In that case, please update Authentication handler to use e.g. "C:/" like this:

e.Accept(new FileServerUser(e.UserName, e.Password, "c:/"));
...