kssh

package
v0.0.0-...-e70d3af Latest Latest
Warning

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

Go to latest
Published: Jan 16, 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 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)

Get the default bot and team for kssh

func GetDefaultSSHUser

func GetDefaultSSHUser() (string, error)

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

func GetKBFSOperationsStruct

func GetKBFSOperationsStruct() *shared.KBFSOperation

func GetKeybaseBinaryPath

func GetKeybaseBinaryPath() string

func GetSignedKey

func GetSignedKey(config ConfigFile, request shared.SignatureRequest) (shared.SignatureResponse, error)

Get a signed SSH key from interacting with the CA chatbot

func GetTeamFromBot

func GetTeamFromBot(botname string) (string, error)

Get the teamname associated with the given botname

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

Set the default keybaseca bot to communicate with.

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 ConfigFile

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

A ConfigFile that is provided by the keybaseca server process and lives in kbfs. It is used to share configuration information about how kssh should communicate with the keybaseca chatbot.

func LoadConfig

func LoadConfig(kbfsFilename string) (ConfigFile, error)

Load a kssh client config file from the given filename

func LoadConfigs

func LoadConfigs(requestName string) ([]ConfigFile, []string, error)

LoadConfigs loads client configs from KBFS. Returns a (listOfConfigFiles, listOfBotNames, err) Both lists are deduplicated based on ConfigFile.BotName. Runs the KBFS operations in parallel to speed up loading configs.

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 (since `LoadConfigs can be very slow if the user is in a large number of teams). 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/atvenu/bot-sshca/pull/3#discussion_r302740696

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

Jump to

Keyboard shortcuts

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