Quantcast
Channel: sshnet Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1026

Commented Issue: SshAuthenticationException : User cannot be authenticated [1547]

$
0
0
Getting SshAuthenticationException : User cannot be authenticated when trying to authenticate with username/password+private key(dsa, 2048bits w/o passphrase)

```
var connectionInfo = new ConnectionInfo(host, 22, username, new PasswordAuthenticationMethod(username, password),
new PrivateKeyAuthenticationMethod(username, new PrivateKeyFile(File.OpenRead(key_path))));

using (var sftp = new SftpClient(connectionInfo))
{
sftp.Connect();
```
Comments: ** Comment from web user: Alfbox **

Spent some time for debugging. Seems like it's not because of key length. It's because server don't returns partial_success == true even if one part of auth sucessfully passed. But there is solution: server decreases list of AllowedAuthentications in case of partial success. So we can change in ConnectionInfo.cs(line 419):
```
if (authenticated == AuthenticationResult.PartialSuccess)
```
to

```
if (authenticated == AuthenticationResult.PartialSuccess || (method.AllowedAuthentications != null && method.AllowedAuthentications.Count() < allowedAuthentications.Count()))
```

and everything works fine :)


Viewing all articles
Browse latest Browse all 1026

Trending Articles