ssh

package
v0.43.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetSSHVersion = sync.OnceValue(func() SSHVersion {
	b, err := exec.Command(SSHExe(), "-V").CombinedOutput()
	if err != nil {
		return SSHVersion{}
	}
	m := regexp.MustCompile(`OpenSSH_(\d+).(\d+)`).FindSubmatch(b)
	if len(m) == 3 {
		maj, _ := strconv.Atoi(utils.UnsafeBytesToString(m[1]))
		min, _ := strconv.Atoi(utils.UnsafeBytesToString(m[2]))
		return SSHVersion{Major: maj, Minor: min}
	}
	return SSHVersion{}
})
View Source
var RelevantKittyOpts = sync.OnceValue(func() KittyOpts {
	return read_relevant_kitty_opts()
})
View Source
var SSHExe = sync.OnceValue(func() string {
	return utils.FindExe("ssh")
})
View Source
var SSHOptions = sync.OnceValue(func() (ssh_options map[string]string) {
	defer func() {
		if ssh_options == nil {
			ssh_options = map[string]string{
				"4": "", "6": "", "A": "", "a": "", "C": "", "f": "", "G": "", "g": "", "K": "", "k": "",
				"M": "", "N": "", "n": "", "q": "", "s": "", "T": "", "t": "", "V": "", "v": "", "X": "",
				"x": "", "Y": "", "y": "", "B": "bind_interface", "b": "bind_address", "c": "cipher_spec",
				"D": "[bind_address:]port", "E": "log_file", "e": "escape_char", "F": "configfile", "I": "pkcs11",
				"i": "identity_file", "J": "[user@]host[:port]", "L": "address", "l": "login_name", "m": "mac_spec",
				"O": "ctl_cmd", "o": "option", "p": "port", "Q": "query_option", "R": "address",
				"S": "ctl_path", "W": "host:port", "w": "local_tun[:remote_tun]",
			}
		}
	}()
	cmd := exec.Command(SSHExe())
	var stdout, stderr bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	_ = cmd.Run()

	text := stderr.String()
	if text == "" || strings.Contains(text, "OpenSSL version mismatch.") {

		return
	}
	ssh_options = make(map[string]string, 32)
	for {
		pos := strings.IndexByte(text, '[')
		if pos < 0 {
			break
		}
		num := 1
		epos := pos
		for num > 0 {
			epos++
			switch text[epos] {
			case '[':
				num += 1
			case ']':
				num -= 1
			}
		}
		q := text[pos+1 : epos]
		text = text[epos:]
		if len(q) < 2 || !strings.HasPrefix(q, "-") {
			continue
		}
		opt, desc, found := strings.Cut(q, " ")
		if found {
			ssh_options[opt[1:]] = desc
		} else {
			for _, ch := range opt[1:] {
				ssh_options[string(ch)] = ""
			}
		}
	}
	return
})

Functions

func EntryPoint

func EntryPoint(parent *cli.Command)

func GetSSHCLI

func GetSSHCLI() (boolean_ssh_args *utils.Set[string], other_ssh_args *utils.Set[string])

func ParseSSHArgs

func ParseSSHArgs(args []string, extra_args ...string) (ssh_args []string, server_args []string, passthrough bool, found_extra_args []string, err error)

func PassthroughArgs

func PassthroughArgs() map[string]bool

func RunSSHAskpass

func RunSSHAskpass() int

func TestEntryPoint

func TestEntryPoint(root *cli.Command)

Types

type ConfigSet

type ConfigSet struct {
	// contains filtered or unexported fields
}

type CopyInstruction

type CopyInstruction struct {
	// contains filtered or unexported fields
}

func ParseCopyInstruction

func ParseCopyInstruction(spec string) (ans []*CopyInstruction, err error)

type EnvInstruction

type EnvInstruction struct {
	// contains filtered or unexported fields
}

func ParseEnvInstruction

func ParseEnvInstruction(spec string) (ans []*EnvInstruction, err error)

func (*EnvInstruction) Serialize

func (self *EnvInstruction) Serialize(for_python bool, get_local_env func(string) (string, bool)) string

type ErrInvalidSSHArgs

type ErrInvalidSSHArgs struct {
	Msg string
}

func (*ErrInvalidSSHArgs) Error

func (self *ErrInvalidSSHArgs) Error() string

type KittyOpts

type KittyOpts struct {
	Term, Shell_integration string
}

type SSHVersion

type SSHVersion struct{ Major, Minor int }

func (SSHVersion) SupportsAskpassRequire

func (self SSHVersion) SupportsAskpassRequire() bool

Jump to

Keyboard shortcuts

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