Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSHAuthAbortError(Connection closed before authentication) when using jumpServer #83

Open
mostcute opened this issue Jul 7, 2023 · 3 comments

Comments

@mostcute
Copy link

mostcute commented Jul 7, 2023

import 'dart:convert';

import 'package:dartssh2/dartssh2.dart';

void main() async {
  final jumpServer = SSHClient(
    await SSHSocket.connect('pubnetip  on HostA', 22222),
    username: 'root',
    onPasswordRequest: () => 'xxxxx',
  );
  print("jumpServer ");

  final client = SSHClient(
    await jumpServer.forwardLocal('internal ip on HostB', 22),
    username: 'root',
    onPasswordRequest: () => 'xxxxx',
  );
  print("client ");
  print(utf8.decode(await client.run('hostname')));
  print(utf8.decode(await client.run('ifconfig')));
  print("client close");
  client.close();
  jumpServer.close();
}

the code can work sometimes,but it will meet err mosttime

E/flutter (22717): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SSHAuthAbortError(Connection closed before authentication)

@DevAloshe
Copy link

same error ):

@XavierChanth
Copy link

XavierChanth commented Dec 9, 2023

After client = SSHClient(...);, try:

  try {
    // Ensure we are connected and authenticated correctly
    await client.ping().catchError((e) => throw e);
  } catch (e, s) {
    // Handle SSH auth errors here
  }

Initially, I had:

  try {
    // Ensure we are connected and authenticated correctly
    await client.authenticated.catchError((e) => throw e);
  } catch (e, s) {
    // Handle SSH auth errors here
  }

but I was experiencing the same SSHAuthAbortError when I did that.
This sends a keep alive to the server, in addition to waiting for authentication to complete.

@wukgdu
Copy link

wukgdu commented Mar 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants