react-ssh2-hook
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

Description

React hook to init shell connection via ssh.

Requirements

Installation

Using npm:

npm install react-ssh2-hook

Using yarn:

yarn add react-ssh2-hook

Get started

Simple example

const { initShell, stream } = useShell({
  // See ssh2 lib documentation
  config: {host: 'host', username: 'username', password: 'password'},
  window: { term: 'xterm-256color' },
  onConnect: () => console.log('connected'),
  onData: (data: string) => console.log(data),
  onClose: () => console.log('closed'),
  onError: (err: Error) => console.error(err),
});

Connection hopping

const { initShell, stream } = useShell({
  // Pass an array of SSH2 ConnectConfig
  config: [
      {host: 'host1', username: 'username1', password: 'password1'},
      {host: 'host2', username: 'username2', password: 'password2'}
  ],
  window: { term: 'xterm-256color' },
});

Package Sidebar

Install

npm i react-ssh2-hook

Weekly Downloads

24

Version

0.5.0

License

none

Unpacked Size

9.82 kB

Total Files

11

Last publish

Collaborators

  • thimal