SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

SftpClient.Connect keeps retrying even on authentication failure

Open superware opened this issue 2 years ago • 3 comments

Hello,

SftpClient.Connect() retries connection attempts even on authentication failure, should return immediately.

var connectionInfo = new ConnectionInfo("host", "username", new[]
{
	new PasswordAuthenticationMethod("username", "password")
})
{
	Timeout = TimeSpan.FromMilliseconds(5000),
	RetryAttempts = 1
};

var sftpClient = new SftpClient(connectionInfo);

sftpClient.Connect();

Retrying with the same invalid credentials sounds wrong, plus Connect() takes longer until timeout, plus might throw on either password OR connection timeout (randomly).

Thank you in advance.

superware avatar Jul 27 '23 11:07 superware

Hi @WojciechNagorski, what do you think about SftpClient.Connect not failing immediately (keeps retying) when authentication fails?

superware avatar Oct 01 '23 13:10 superware

@superware TBH I do not have time for this topic right now. I want to focus on tasks that involve a large number of people first. I encourage you to propose a PR. I will review it then.

WojciechNagorski avatar Oct 01 '23 15:10 WojciechNagorski

@superware, we should not retry in case of authentication failures. Are you sure that's what you're seeing?

drieseng avatar Oct 02 '23 19:10 drieseng