dartssh2 icon indicating copy to clipboard operation
dartssh2 copied to clipboard

SSHAuthAbortError(Connection closed before authentication)

Open ssddOnTop opened this issue 2 years ago • 4 comments

I've vsftp hosted on my vps but whenever I try to connect via sftp it shows this err.

Tue Apr 26 03:08:58 2022 [pid 8454] CONNECT: Client "::ffff:ip>"

this is all it shows in the log, I tried to connect with filezilla by copy pasting ip, port, username and pw and it worked perfectly so there isn't any mistake in credentials.

The dart code is same as documented

final sftp = await client.sftp(); final items = await sftp.listdir('/'); for (final item in items) { print(item.longname); }

ssddOnTop avatar Apr 26 '22 03:04 ssddOnTop

Hello @ssddOnTop, like you I wanted to use SFTP and ran into the same issue. It turns out the error isn't coming from the lines of code you shared but the following that you can find in the example:

final client = SSHClient(  
await SSHSocket.connect('localhost', 22),
username: 'root',  
onPasswordRequest: () {  
  stdout.write('Password: ');  
  stdin.echoMode = false;  
  return stdin.readLineSync() ?? exit(1);  
},

I think the examples might be outdated, and you should replace it with what you now find in the latest README:

final client = SSHClient(
await SSHSocket.connect('localhost', 22),
username: '<username>',
onPasswordRequest: () => '<password>',
);

Don't forget to replace "username" and "password" accordingly, after what you should be able to use this sftp library as intended. I managed to do what you tried to do as well as uploading a file, and it worked like a charm.

Hope this helps.

Adrien-pierret avatar May 12 '22 02:05 Adrien-pierret

I'm having the same error while using this code It's from a method inside a class

void connect() async {
    final client = SSHClient(
      await SSHSocket.connect(address, port),
      username: this.user,
      onPasswordRequest: () => "pass",
    );
    
    final shell = await client.shell();
    print(shell.stdout);

    client.close();
    await client.done;
    print('closed');
}

but if I run it like this the error doesn't happen

void connect() async {
    final client = SSHClient(
      await SSHSocket.connect(address, port),
      username: user,
      onPasswordRequest: () => "pass",
    );

    client.close();
    await client.done;
    print('closed');
}

So it looks like the package is having issues running a command

biel-correa avatar Jun 12 '22 13:06 biel-correa

same error here

aqueebqazi avatar Aug 28 '23 08:08 aqueebqazi

could check the version of ssh server this lib checks SSH2 in meta data received from the server, so if the ssh server is 1.xSSHAuthAbortError(Connection closed before authentication) will occur

wukgdu avatar Mar 29 '24 10:03 wukgdu