0.5.0 • Published 3 years ago

react-ssh2-hook v0.5.0

Weekly downloads
8
License
-
Repository
github
Last release
3 years ago

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' },
});