webssh

package
v0.0.0-...-6ed5ca5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

Make HTTP Handler

import (
	"github.com/OutOfBedlam/webterm"
	"github.com/OutOfBedlam/webterm/webssh"
)

mux := http.NewServeMux()
mux.Handle("/web/ssh/", makeSSH("/web/ssh/"))

func makeSSH(cutPrefix string) http.Handler {
	key, _ := os.ReadFile(filepath.Join(os.Getenv("HOME"), ".ssh/id_rsa"))
	user := os.Getenv("USER")

	term := webterm.New(
		&webssh.WebSSH{
			Host: "127.0.0.1",
			Port: 22,
			User: user,
			Auth: []ssh.AuthMethod{
				webssh.AuthPrivateKey(key),
			},
			TermType: "xterm-256color",
		},
		webterm.WithCutPrefix(cutPrefix),
		webterm.WithTheme(webterm.ThemeMolokai),
	)
	return term
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthPassword

func AuthPassword(password string) ssh.AuthMethod

func AuthPasswordCallback

func AuthPasswordCallback(fn func() (string, error)) ssh.AuthMethod

func AuthPrivateKey

func AuthPrivateKey(key []byte) ssh.AuthMethod

func AuthPrivateKeyWithPassphrase

func AuthPrivateKeyWithPassphrase(key []byte, passphrase string) ssh.AuthMethod

Types

type Hop

type Hop struct {
	Network string
	Host    string
	Port    int
	User    string
	Auth    []ssh.AuthMethod
}

type Hops

type Hops []Hop

func (Hops) Connect

func (hops Hops) Connect() (*ssh.Client, error)

type WebSSH

type WebSSH struct {
	Hops     Hops
	TermType string
	Command  string
}

func (*WebSSH) Session

func (ws *WebSSH) Session() (webterm.Session, error)

func (*WebSSH) Template

func (ws *WebSSH) Template() (*template.Template, any)

type WebSSHSession

type WebSSHSession struct {
	WebSSH
	// contains filtered or unexported fields
}

func (*WebSSHSession) Close

func (ws *WebSSHSession) Close() error

func (*WebSSHSession) Control

func (ws *WebSSHSession) Control(data []byte) error

func (*WebSSHSession) Open

func (ws *WebSSHSession) Open() error

func (*WebSSHSession) Read

func (ws *WebSSHSession) Read(p []byte) (n int, err error)

func (*WebSSHSession) SetWinSize

func (ws *WebSSHSession) SetWinSize(cols, rows int) error

func (*WebSSHSession) Write

func (ws *WebSSHSession) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL