dartssh2
dartssh2 copied to clipboard
SSHAuthAbortError(Connection closed before authentication)
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); }
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.
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
same error here
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.x
,SSHAuthAbortError(Connection closed before authentication)
will occur