Does anyone know if it is possible to programmatically change a users password on an SFTP site using SSH.NET library (Renci.SshNet)? I have not been able to find anything definitive either way.
If it is I would appreciate any pointers you can provide.
No. While there's an API in the SSH protocol to change a password on request, the explicitly request is not implemented by the SSH.NET library.
In the SSH.NET library, you can only only change the password, if the server asks for it. Typically a servers asks for a password change, when the previous password has expired. In the SSH.NET library, this server request is implemented as the PasswordExpired
event.
Though if you are willing to modify the SSH.NET library, see the PasswordAuthenticationMethod.Session_UserAuthenticationPasswordChangeRequiredReceived
method. It sends the password change request like:
_session.SendMessage(
new RequestMessagePassword(
ServiceName.Connection, Username, _password, eventArgs.NewPassword))
If you implement your own AuthenticationMethod
that sends the RequestMessagePassword
with the eventArgs.NewPassword
directly in the implementation of the Authenticate
method, it should do what you need.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.