Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/dev-tunnels-ssh-tcp

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/dev-tunnels-ssh-tcp

SSH TCP extensions library for Dev Tunnels

  • 3.12.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
increased by9.12%
Maintainers
0
Weekly downloads
 
Created
Source

Dev Tunnels SSH TCP Library

Includes SshClient and SshServer convenience classes for establishing SSH sessions over TCP, and the PortForwardingService class that enables forwarding TCP ports between client and server.

Examples

Forward from a server port to a client port

// Port-forwarding is not enabled by default. It must be added to the session configuration
// on both client and server sides.
const config = new SshSessionConfiguration();
config.addService(PortForwardingService);

const client = new SshClient(config);
const session: SshClientSession = await client.openSession(host, port);

// Handle server and client authentication.
session.onAuthenticating((e) => { ... });
if (!(await session.authenticate(credentials))) {
	throw new Error('Authentication failed.');
}

// Start port-forwarding.
const pfs = session.activateService(PortForwardingService);
const forwarder: RemotePortForwarder = await pfs.forwardFromRemotePort('::', remotePort);
// Connections to the port on the server will now be forwarded to
// the same port on the client.
forwarder.dispose();
// New connections to the server port are no longer forwarded.
// (Existing forwarded connections may remain alive until the session is closed.)

Stream to a server port

const session: SshClientSession = ...

const pfs = session.activateService(PortForwardingService);
const stream: SshStream = await pfs.streamToRemotePort('localhost', remotePort);
// The stream data is forwarded to/from the port on the server.

Browser compatibility

This package has limited capabilities when running in a browser. Obviously a browser cannot access local TCP ports. However, it is possible to stream to/from server ports. The streamFromRemotePort() and streamToRemotePort() methods are validated working in a browser environment.

Keywords

FAQs

Package last updated on 26 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc