How to Use Public Key Authentication with SFTP Server

0
Can you please provide an example of how public key authentication works with sftp server? I'm guessing something like: ``` server.PreAuthentication = ServerOnPreAuthentication; private static void ServerOnPreAuthentication(object sender, PreAuthenticationEventArgs e) { e.Accept(AuthenticationMethods.PublicKey); } ``` And then maybe something like this: ``` server.Authentication = ServerOnAuthentication; private static void ServerOnAuthentication(object sender, AuthenticationEventArgs e) { if (e.Key.???) { var user = AddUser((SftpSshServer)sender, e.UserName, e.Password, userPath); e.Accept(user); } else { e.Reject(); } } ``` The problem is e.Key is always null for me, no matter what I do. I am testing this with FileZilla and a Logon Type of Key file where I specify a ppk file.
 
asked 12/17/2019 8:22:59 PM
add a comment

1 Answers

0
You need to set the allowed authentication methods in `AllowedAuthenticationMethods` in `ServerConfig` to public/private key only. That config instance can be accessed from `SshServerCore.Config`.
 
answered 12/21/2019 6:23:43 AM
  How do we validate the fingerprint of the key? bentoo 1/6/2020 5:58:54 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged ultimate sftp sftp server sftp or ask your own question.