0.1.0 • Published 4 years ago

@coder/sshclient v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

sshclient ¡ MIT license "Latest Release"

sshclient is a JavaScript library to process client SSH connections. It communicates with an OpenSSH server.

❤️ to gopherjs. sshclient uses the golang.org/x/crypto/ssh implementation. Currently the following functionality has been exposed from their API:

  • Port forwarding
  • PTYs
  • Exec

Usage

import * as sshclient from "@coder/sshclient"

// The server hosting this socket is serving sshd on
// port 22 from the host.
const socket = new WebSocket("ws://localhost:8080/ssh")
socket.binaryType = "arraybuffer"
socket.addEventListener("open", () => {
    const conn = sshclient.createConnection((data) => {
        socket.send(data)
    })

    socket.addEventListener("message", (event) => {
        conn.writeToClient(new Uint8Array(event.data))
    })

    sshclient.createClient(conn, {
        username: "kyle",
        password: "example",
    }).then((client) => {
        // 🎊
    })
})

Development

You must have gopherjs and Go 1.12.

yarn
yarn dev

Go source code will be transformed and hot-reloaded by Webpack via gopherjs-loader.js.

License

MIT