Skip to main content

system_ssh 0.3.0 copy "system_ssh: ^0.3.0" to clipboard
system_ssh: ^0.3.0 copied to clipboard

SSH tunnels for Dart through the system's own ssh, so ~/.ssh/config, agents such as 1Password, and ProxyJump just work.

example/system_ssh_example.dart

import 'dart:async';
import 'dart:io';

import 'package:system_ssh/system_ssh.dart';

Future<void> main() async {
  const client = SystemSshClient();

  final SshTunnel tunnel;
  try {
    tunnel = await client.openTunnel(
      const SshTarget('ssh.example.com'),
      remoteHost: 'db.example.com',
      remotePort: 5432,
    );
  } on SshTunnelException catch (exception) {
    stderr.writeln('ssh failed: ${exception.message}');
    exitCode = 1;
    return;
  } on SshException catch (exception) {
    stderr.writeln(exception.message);
    exitCode = 1;
    return;
  }

  print('db.example.com:5432 is on 127.0.0.1:${tunnel.localPort}');
  await Future.any([ProcessSignal.sigint.watch().first, tunnel.done]);
  await tunnel.close();
}
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

verified publisherpacabase.com

Weekly Downloads

SSH tunnels for Dart through the system's own ssh, so ~/.ssh/config, agents such as 1Password, and ProxyJump just work.

Repository (GitHub)
View/report issues

Topics

#ssh #openssh #tunnel #port-forwarding

License

BSD-3-Clause (license)

Dependencies

ffi, logging

More

Packages that depend on system_ssh