cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cmd implements dispatching commands on the SSH gateway using SSH's "exec" requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command func(ctx context.Context, conn *ssh.Permissions, env map[string]string, rw io.ReadWriter) error

Command is the function signature of a command. It has access to the permissions of the connected user, the environment set by the connected user, and it can read/write to the channel.

func ListUpstreams

func ListUpstreams(dataDir string) Command

ListUpstreams lists the upstreams that the connected user is allowed to connect to.

func UpstreamConfig

func UpstreamConfig(dataDir string) Command

UpstreamConfig generates an SSH config template.

Make sure that you have a directory ~/.ssh/config.d and that you have a line

Include config.d/*

in your ~/.ssh/config. Then you can update the SSH config as follows:

ssh -p 2222 gateway@localhost config | sed -e 's/$SSH_HOST/localhost/g' -e 's/$SSH_PORT/2222/g' > ~/.ssh/config.d/ssh_gateway

If the SSH gateway has the SSH_HOST and SSH_PORT preconfigured, you can update the SSH config as follows:

ssh -p 2222 gateway@localhost config > ~/.ssh/config.d/ssh_gateway

You should obviously replace the host "localhost" and port "2222" if that is different in your deployment.

type Dispatcher

type Dispatcher map[string]Command

Dispatcher is a collection of named commands.

func (Dispatcher) Dispatch

func (r Dispatcher) Dispatch(ctx context.Context, sshConn *ssh.ServerConn, sshChannels <-chan ssh.NewChannel, sshRequests <-chan *ssh.Request) error

Dispatch dispatches commands.

Jump to

Keyboard shortcuts

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