kssh

package
v0.0.0-...-1b8ee3a Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AlternateSSHConfigFile = shared.ExpandPathWithTilde("~/.ssh/kssh-config")

Functions

func AddKeyToSSHAgent

func AddKeyToSSHAgent(keyPath string) error

Add the SSH key at the given location to the currently running SSH agent. Errors if there is no running ssh-agent.

func ClearDefaultBot

func ClearDefaultBot() error

ClearDefaultBot clears the default bot and team.

func CreateDefaultUserConfigFile

func CreateDefaultUserConfigFile(keyPath string) error

Create an SSH config file that inherits from the default SSH config file but sets a default SSH user

func GetDefaultBotAndTeam

func GetDefaultBotAndTeam() (string, string, error)

GetDefaultBotAndTeam gets the default bot and team for kssh from the local config file.

func GetDefaultSSHUser

func GetDefaultSSHUser() (string, error)

Get the default SSH user to use for kssh connections. Empty if no user is configured.

func GetKeybaseBinaryPath

func GetKeybaseBinaryPath() string

func InitLogging

func InitLogging()

func MakeDotSSH

func MakeDotSSH() error

Make the ~/.ssh/ folder if it does not exist

func SetDefaultBot

func SetDefaultBot(botName string) error

SetDefaultBot sets the default keybaseca bot and team to communicate with. If given a botName, will need to start a Keybase bot to find and load all configs from KV store, in order to find the team associated with the given botName.

func SetDefaultSSHUser

func SetDefaultSSHUser(username string) error

Set the default SSH user to use for kssh connections.

func SetKeybaseBinaryPath

func SetKeybaseBinaryPath(path string) error

Set the default SSH user to use for kssh connections.

Types

type CLIArgument

type CLIArgument struct {
	// The name of the flag eg "--foo"
	Name string

	// HasArgument:true if an argument comes after it (eg "--foo bar") false if it is a boolean flag (eg "--help")
	HasArgument bool

	// Preserve:true if you wish to preserve this argument into the list of remaining arguments even if found
	// eg if your command takes in a `-v` flag and the subcommand also takes in a `-v` flag
	// incompatible with HasArgument: true but only because that has not been built
	Preserve bool
}

type Config

type Config struct {
	TeamName    string `json:"teamname"`
	ChannelName string `json:"channelname"`
	BotName     string `json:"botname"`
}

Config is provided by the keybaseca server and lives in the KV store. It is used to share configuration information about how kssh should communicate with the keybaseca chat bot.

type LocalConfigFile

type LocalConfigFile struct {
	DefaultBotName string `json:"default_bot"`
	DefaultBotTeam string `json:"default_team"`
	DefaultSSHUser string `json:"default_ssh_user"`
	KeybaseBinPath string `json:"keybase_binary"`
}

A LocalConfigFile is a file that lives on the FS of the computer running kssh. By default (and for most users), this file is not used.

If a user of kssh is in in multiple teams that are running the CA bot they can configure a default bot to communicate with. Note that we store the team in here (even though it wasn't specified by the user) so that we can avoid doing a call to `LoadConfigs` if a default is set. This is controlled via `kssh --set-default-bot foo`.

If a user of kssh wishes to configure a default ssh user to use (see README.md for a description of why this may be useful) this is also stored in the local config file. This is controlled via `kssh --set-default-user foo`.

type ParsedCLIArgument

type ParsedCLIArgument struct {
	// The CLIArgument that was found and parsed
	Argument CLIArgument

	// The value associated with it if HasArgument:true. Otherwise an empty string.
	Value string
}

func ParseArgs

func ParseArgs(args []string, cliArguments []CLIArgument) ([]string, []ParsedCLIArgument, error)

ParseArgs parses os.Args for use with kssh. This is handwritten rather than using go's flag library (or any other CLI argument parsing library) since we want to have custom arguments and access any other remaining arguments. See this Github discussion for a longer discussion of why this is implemented this way: https://github.com/keybase/bot-sshca/pull/3#discussion_r302740696

Returns: a list of the remaining unparsed arguments, a list of the parsed arguments, error

type Requester

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

func NewRequester

func NewRequester() (r Requester, err error)

NewRequester creates a new Requester with a Keybase chat API

func (*Requester) GetSignedKey

func (r *Requester) GetSignedKey(botName string, request shared.SignatureRequest) (shared.SignatureResponse, error)

Get a signed SSH key from interacting with the CA chatbot

func (*Requester) LoadConfig

func (r *Requester) LoadConfig(teamName string) (*Config, error)

LoadConfig loads the kssh config for the given teamName. Will return a nil Config if no config was found for the teamName (and no error occurred)

func (*Requester) LoadConfigForBot

func (r *Requester) LoadConfigForBot(botName string) (Config, error)

LoadConfigForBot gets the Config associated with the given botName. Will need to find and load all configs from KV store.

func (*Requester) LoadConfigs

func (r *Requester) LoadConfigs() (configs []Config, botNames []string, err error)

LoadConfigs loads kssh configs from the KV store. Returns a (listOfConfigs, listOfBotNames, err). Both lists are deduplicated based on Config.BotName.

Jump to

Keyboard shortcuts

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