{"modulePath":"github.com/brevdev/brev-cli","version":"v0.6.337","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ssh\n\nPackage ssh exists to provide an api to configure and read from an ssh file\n\nbrev ssh host file entry format:\n\n\tHost \u003cworkspace-dns-name\u003e\n\t\tHostname 0.0.0.0\n\t\tIdentityFile /home//.brev/brev.pem\n\t\tUser brev\n\t\tPort \u003csome-available-port\u003e\n\nalso think that file stuff should probably live in files package TODO migrate to using dns name for hostname\n\n## Constants\n\n```go\nconst SSHCertRequiredTemplateNode = `Match host {{ .Alias }} exec {{ .ExecCommand }}\n  HostName {{ .Hostname }}\n  User {{ .User }}\n  Port {{ .Port }}\n  IdentityFile {{ .IdentityFile }}\n  IdentitiesOnly yes\n  PasswordAuthentication no\n  AddKeysToAgent yes\n  StrictHostKeyChecking no\n  UserKnownHostsFile /dev/null\n  ServerAliveInterval 30\n  ForwardAgent yes\n\n`\n```\n\n```go\nconst SSHCertRequiredTemplateV2 = `Match host {{ .Alias }} exec {{ .ExecCommand }}\n  IdentityFile {{ .IdentityFile }}\n  User {{ .User }}\n  ProxyCommand {{ .ProxyCommand }}\n  ServerAliveInterval 30\n  UserKnownHostsFile /dev/null\n  IdentitiesOnly yes\n  StrictHostKeyChecking no\n  PasswordAuthentication no\n  AddKeysToAgent yes\n  ForwardAgent yes\n  RequestTTY yes\n  ControlMaster auto\n  ControlPath ~/.ssh/brev-control-%C\n  ControlPersist 10m\n{{ if .RunRemoteCMD }}\n  RemoteCommand cd {{ .Dir }}; $SHELL\n{{ end }}\n`\n```\n\n```go\nconst SSHCertRequiredTemplateV3 = `Match host {{ .Alias }} exec {{ .ExecCommand }}\n  Hostname {{ .HostName }}\n  IdentityFile {{ .IdentityFile }}\n  User {{ .User }}\n  ServerAliveInterval 30\n  UserKnownHostsFile /dev/null\n  IdentitiesOnly yes\n  StrictHostKeyChecking no\n  PasswordAuthentication no\n  AddKeysToAgent yes\n  ForwardAgent yes\n  RequestTTY yes\n  ControlMaster auto\n  ControlPath ~/.ssh/brev-control-%C\n  ControlPersist 10m\n  Port {{ .Port }}\n{{ if .RunRemoteCMD }}\n  RemoteCommand cd {{ .Dir }}; $SHELL\n{{ end }}\n`\n```\n\n```go\nconst SSHConfigEntryTemplateNode = `Host {{ .Alias }}\n  HostName {{ .Hostname }}\n  User {{ .User }}\n  Port {{ .Port }}\n  IdentityFile {{ .IdentityFile }}\n  StrictHostKeyChecking no\n  UserKnownHostsFile /dev/null\n  ServerAliveInterval 30\n  ForwardAgent yes\n\n`\n```\n\n```go\nconst SSHConfigEntryTemplateV2 = `Host {{ .Alias }}\n  IdentityFile {{ .IdentityFile }}\n  User {{ .User }}\n  ProxyCommand {{ .ProxyCommand }}\n  ServerAliveInterval 30\n  UserKnownHostsFile /dev/null\n  IdentitiesOnly yes\n  StrictHostKeyChecking no\n  PasswordAuthentication no\n  AddKeysToAgent yes\n  ForwardAgent yes\n  RequestTTY yes\n  ControlMaster auto\n  ControlPath ~/.ssh/brev-control-%C\n  ControlPersist 10m\n{{ if .RunRemoteCMD }}\n  RemoteCommand cd {{ .Dir }}; $SHELL\n{{ end }}\n`\n```\n\n```go\nconst SSHConfigEntryTemplateV3 = `Host {{ .Alias }}\n  Hostname {{ .HostName }}\n  IdentityFile {{ .IdentityFile }}\n  User {{ .User }}\n  ServerAliveInterval 30\n  UserKnownHostsFile /dev/null\n  IdentitiesOnly yes\n  StrictHostKeyChecking no\n  PasswordAuthentication no\n  AddKeysToAgent yes\n  ForwardAgent yes\n  RequestTTY yes\n  ControlMaster auto\n  ControlPath ~/.ssh/brev-control-%C\n  ControlPersist 10m\n  Port {{ .Port }}\n{{ if .RunRemoteCMD }}\n  RemoteCommand cd {{ .Dir }}; $SHELL\n{{ end }}\n`\n```\n\n```go\nconst (\n\tWindowsSupport = false // cannot execute mint-cert on Windows\n)\n```\n\n## Functions\n\n```go\nfunc AddIncludeToUserConfig(conf string, brevConfigPath string) (string, error)\n```\n\n```go\nfunc MakeSSHEntry(workspaceIdentifier entity.WorkspaceLocalID, port string, privateKeyPath string, dir string) (string, error)\n```\n\n```go\nfunc SanitizeNodeName(name string) string\n```\nSanitizeNodeName converts a node display name into a valid SSH Host alias.\n\n```go\nfunc WSLAddIncludeToUserConfig(conf string, brevConfigPath string) string\n```\n\n## Types\n\n```go\ntype BrevHostValuesSet map[entity.WorkspaceLocalID]bool\n```\n\n```go\ntype BrevPorts map[string]bool\n```\n\n```go\ntype Config interface {\n\tUpdate(workspaces []entity.Workspace, nodes []ExternalNodeSSHEntry) error\n}\n```\n\n```go\nfunc GetSSHConfigs(store SSHConfigurerTaskStore) ([]Config, error)\n```\n\n```go\ntype ConfigUpaterFactoryStore interface {\n\tConfigUpdaterStore\n\tSSHConfigurerV2Store\n}\n```\nConfigUpaterFactoryStore prob a better way to do this\n\n```go\ntype ConfigUpdater struct {\n\tStore         ConfigUpdaterStore\n\tConfigs       []Config\n\tPrivateKey    string\n\tExternalNodes []ExternalNodeSSHEntry\n}\n```\n\n```go\nfunc NewConfigUpdater(store ConfigUpdaterStore, configs []Config, privateKey string) *ConfigUpdater\n```\n\n```go\nfunc (c ConfigUpdater) Configure() error\n```\n\n```go\nfunc (c ConfigUpdater) GetTaskSpec() tasks.TaskSpec\n```\n\n```go\nfunc (c ConfigUpdater) Run() error\n```\n\n```go\ntype ConfigUpdaterStore interface {\n\tautostartconf.AutoStartStore\n\tGetContextWorkspaces() ([]entity.Workspace, error)\n\tWritePrivateKey(pem string) error\n}\n```\n\n```go\ntype ExternalNodeSSHEntry struct {\n\tAlias    string\n\tNodeID   string\n\tPortID   string\n\tHostname string\n\tPort     int32\n\tUser     string\n}\n```\nExternalNodeSSHEntry holds pre-resolved SSH details for an external node.\n\n```go\ntype IdentityPortMap map[entity.WorkspaceLocalID]string\n```\n\n```go\ntype JetBrainsGatewayConfig struct {\n\tReader\n\tWriter\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewJetBrainsGatewayConfig(store JetBrainsGatewayConfigStore) (*JetBrainsGatewayConfig, error)\n```\n\n```go\nfunc (jbgc *JetBrainsGatewayConfig) GetBrevHostValueSet() BrevHostValuesSet\n```\n\n```go\nfunc (jbgc *JetBrainsGatewayConfig) GetBrevPorts() (BrevPorts, error)\n```\n\n```go\nfunc (jbgc *JetBrainsGatewayConfig) GetConfiguredWorkspacePort(workspaceIdentifier entity.WorkspaceLocalID) (string, error)\n```\n\n```go\nfunc (jbgc *JetBrainsGatewayConfig) Sync(identifierPortMapping IdentityPortMap) error\n```\n\n```go\ntype JetBrainsGatewayConfigStore interface {\n\tGetJetBrainsConfigPath() (string, error)\n\tGetJetBrainsConfig() (string, error)\n\tWriteJetBrainsConfig(config string) error\n\tGetPrivateKeyPath() (string, error)\n}\n```\n\n```go\ntype JetbrainsGatewayConfigXML struct {\n\tXMLName   xml.Name                           `xml:\"application\"`\n\tComponent JetbrainsGatewayConfigXMLComponent `xml:\"component\"`\n}\n```\n\n```go\nfunc ParseJetbrainsGatewayXML(config string) (*JetbrainsGatewayConfigXML, error)\n```\n\n```go\ntype JetbrainsGatewayConfigXMLComponent struct {\n\tConfigs JetbrainsGatewayConfigXMLConfigs `xml:\"configs\"`\n\tName    string                           `xml:\"name,attr,omitempty\"`\n}\n```\n\n```go\ntype JetbrainsGatewayConfigXMLConfigs struct {\n\tSSHConfigs []JetbrainsGatewayConfigXMLSSHConfig `xml:\"sshConfig\"`\n}\n```\n\n```go\ntype JetbrainsGatewayConfigXMLSSHConfig struct {\n\tID               string                               `xml:\"id,attr,omitempty\"`\n\tCustomName       entity.WorkspaceLocalID              `xml:\"customName,attr,omitempty\"`\n\tNameFormat       string                               `xml:\"nameFormat,attr,omitempty\"`\n\tUseOpenSSHConfig string                               `xml:\"useOpenSSHConfig,attr,omitempty\"`\n\tHost             string                               `xml:\"host,attr,omitempty\"`\n\tPort             string                               `xml:\"port,attr,omitempty\"`\n\tKeyPath          string                               `xml:\"keyPath,attr,omitempty\"`\n\tUsername         string                               `xml:\"username,attr,omitempty\"`\n\tConnectionConfig string                               `xml:\"connectionConfig,attr,omitempty\"`\n\tOptions          []JetbrainsGatewayConfigXMLSSHOption `xml:\"option,omitempty\"`\n}\n```\n\n```go\ntype JetbrainsGatewayConfigXMLSSHOption struct {\n\tName  string `xml:\"name,attr,omitempty\"`\n\tValue string `xml:\"value,attr,omitempty\"`\n}\n```\n\n```go\ntype Reader interface {\n\tGetBrevPorts() (BrevPorts, error)\n\tGetBrevHostValueSet() BrevHostValuesSet\n\tGetConfiguredWorkspacePort(workspaceIdentifier entity.WorkspaceLocalID) (string, error)\n}\n```\n\n```go\ntype SSHConfig struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSSHConfig(store SSHStore) (*SSHConfig, error)\n```\n\n```go\nfunc (s SSHConfig) GetBrevHostValueSet() BrevHostValuesSet\n```\n\n```go\nfunc (s SSHConfig) GetBrevHostValues() []entity.WorkspaceLocalID\n```\nHostname is a loaded term so using values\n\n```go\nfunc (s SSHConfig) GetBrevPorts() (BrevPorts, error)\n```\n\n```go\nfunc (s SSHConfig) GetConfiguredWorkspacePort(workspaceIdentifier entity.WorkspaceLocalID) (string, error)\n```\n\n```go\nfunc (s SSHConfig) GetPrivateKeyFilePath() string\n```\n\n```go\nfunc (s *SSHConfig) PruneInactiveWorkspaces(identityPortMap IdentityPortMap) error\n```\n\n```go\nfunc (s *SSHConfig) Sync(identifierPortMapping IdentityPortMap) error\n```\n\n```go\ntype SSHConfigEntryV2 struct {\n\tAlias        string\n\tIdentityFile string\n\tUser         string\n\tProxyCommand string\n\tDir          string\n\tRunRemoteCMD bool\n\tHostName     string\n\tPort         int\n\tExecCommand  string // cert-required Match exec line (templates only)\n}\n```\n\n```go\ntype SSHConfigurer struct {\n\tReader  Reader\n\tWriters []Writer\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSSHConfigurer(workspaces []entity.WorkspaceWithMeta, reader Reader, writers []Writer, store SSHConfigurerStore, privateKey string) *SSHConfigurer\n```\n\n```go\nfunc (sshConfigurer *SSHConfigurer) GetActiveWorkspaceIdentifiers() []entity.WorkspaceLocalID\n```\n\n```go\nfunc (sshConfigurer SSHConfigurer) GetConfiguredWorkspacePort(workspaceIdentifier entity.WorkspaceLocalID) (string, error)\n```\n\n```go\nfunc (sshConfigurer *SSHConfigurer) GetIdentityPortMap() (IdentityPortMap, error)\n```\n\n```go\nfunc (sshConfigurer SSHConfigurer) GetPrivateKeyPath() (string, error)\n```\n\n```go\nfunc (sshConfigurer *SSHConfigurer) Sync() error\n```\n\n```go\ntype SSHConfigurerJetBrains struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSSHConfigurerJetBrains(store SSHConfigurerV2Store) (*SSHConfigurerJetBrains, error)\n```\n\n```go\nfunc (s SSHConfigurerJetBrains) CreateNewSSHConfig(workspaces []entity.Workspace) (string, error)\n```\n\n```go\nfunc (s SSHConfigurerJetBrains) Update(workspaces []entity.Workspace, _ []ExternalNodeSSHEntry) error\n```\n\n```go\ntype SSHConfigurerStore interface {\n\tWritePrivateKey(pem string) error\n}\n```\n\n```go\ntype SSHConfigurerTask struct {\n\tStore SSHConfigurerTaskStore\n}\n```\n\n```go\nfunc NewSSHConfigurerTask(store SSHConfigurerTaskStore) SSHConfigurerTask\n```\n\n```go\nfunc (sct SSHConfigurerTask) Configure() error\n```\n\n```go\nfunc (sct SSHConfigurerTask) GetTaskSpec() tasks.TaskSpec\n```\n\n```go\nfunc (sct SSHConfigurerTask) Run() error\n```\n\n```go\ntype SSHConfigurerTaskStore interface {\n\tConfigUpdaterStore\n\tSSHConfigurerV2Store\n\tGetCurrentUserKeys() (*entity.UserKeys, error)\n}\n```\n\n```go\ntype SSHConfigurerV2 struct {\n\t// contains filtered or unexported fields\n}\n```\nSSHConfigurerV2 speciallizes in configuring ssh config with ProxyCommand\n\n```go\nfunc NewSSHConfigurerV2(store SSHConfigurerV2Store) *SSHConfigurerV2\n```\n\n```go\nfunc (s SSHConfigurerV2) CreateNewSSHConfig(workspaces []entity.Workspace, nodes []ExternalNodeSSHEntry) (string, error)\n```\n\n```go\nfunc (s SSHConfigurerV2) CreateWSLConfig(workspaces []entity.Workspace) (string, error)\n```\n\n```go\nfunc (s SSHConfigurerV2) EnsureConfigHasInclude() error\n```\n\n```go\nfunc (s SSHConfigurerV2) EnsureWSLConfigHasInclude() error\n```\n\n```go\nfunc (s SSHConfigurerV2) Update(workspaces []entity.Workspace, nodes []ExternalNodeSSHEntry) error\n```\n\n```go\ntype SSHConfigurerV2Store interface {\n\tWriteBrevSSHConfig(config string) error\n\tGetUserSSHConfig() (string, error)\n\tWriteUserSSHConfig(config string) error\n\tGetPrivateKeyPath() (string, error)\n\tGetUserSSHConfigPath() (string, error)\n\tGetBrevSSHConfigPath() (string, error)\n\tGetJetBrainsConfigPath() (string, error)\n\tGetJetBrainsConfig() (string, error)\n\tWriteJetBrainsConfig(config string) error\n\tDoesJetbrainsFilePathExist() (bool, error)\n\tGetWSLHostUserSSHConfigPath() (string, error)\n\tGetWindowsDir() (string, error)\n\tWriteBrevSSHConfigWSL(config string) error\n\tGetFileAsString(path string) (string, error)\n\tFileExists(path string) (bool, error)\n\tGetWSLHostBrevSSHConfigPath() (string, error)\n\tGetWSLUserSSHConfig() (string, error)\n\tWriteWSLUserSSHConfig(config string) error\n\tGetBrevCloudflaredBinaryPath() (string, error)\n}\n```\n\n```go\ntype SSHStore interface {\n\tGetUserSSHConfig() (string, error)\n\tWriteUserSSHConfig(config string) error\n\tCreateNewSSHConfigBackup() error\n\tGetPrivateKeyPath() (string, error)\n}\n```\n\n```go\ntype Writer interface {\n\tSync(IdentityPortMap) error\n}\n```\n\n","path":"github.com/brevdev/brev-cli/pkg/ssh","name":"ssh","synopsis":"Package ssh exists to provide an api to configure and read from an ssh file","isRedistributable":true}
