@coder/sshclient

A JavaScript library to process client SSH connections. It communicates with an OpenSSH server.

Usage no npm install needed!

<script type="module">
  import coderSshclient from 'https://cdn.skypack.dev/@coder/sshclient';
</script>

README

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