react-ssh2-hook
v0.5.0
Published
React hooks for SSH
Downloads
148
Maintainers
Readme
Description
React hook to init shell connection via ssh.
Requirements
- node.js -- v10.16.0 or newer
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' },
});