sshutil

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSH_CONFIG_USER        = "config"
	SSH_CONFIG_SYSTEM      = "ssh_config"
	SSH_KNOWN_HOSTS_USER   = "known_hosts"
	SSH_KNOWN_HOSTS_SYSTEM = "ssh_known_hosts"
	HOSTS_USER             = "oinit_hosts"
	HOSTS_SYSTEM           = "ssh_oinit_hosts"
)
View Source
const (
	DEFAULT_SSH_PORT    = 22
	KNOWN_HOSTS_COMMENT = "Added by oinit"
	CONFIG_COMMENT      = `` /* 214-byte string literal not displayed */

)
View Source
const (
	PRINCIPAL = "oinit"
)

Variables

This section is empty.

Functions

func AddSSHKnownHost

func AddSSHKnownHost(host, port, pubkey string) error

AddSSHKnownHost adds a "@cert-authority <hostport> <public key>" to the users known_hosts file if not already present there or system wide.

func AddSSHMatchBlock

func AddSSHMatchBlock() (bool, error)

AddSSHMatchBlock adds the string generated by GenerateMatchBlock() to the user's ssh config file, if not already present there or system-wide. Returns boolean that indicates whether the match block was added or not.

func AgentHasCertificate

func AgentHasCertificate(agent agent.ExtendedAgent, host string) (bool, error)

AgentHasCertificate returns a bool indicating whether a certificate issued by oinit-ca for the given host is currently present in the agent. An error is returned when communication with the agent is not possible, for example if it isn't running.

func AgentIsRunning

func AgentIsRunning() bool

func AgentRemoveCertificates added in v1.1.0

func AgentRemoveCertificates(agent agent.ExtendedAgent, host string) error

AgentRemoveCertificates removes all certificates issued by oinit-ca for the given host from the agent. An error is returned when communication with the agent is not possible, for example if it isn't running.

func GenerateKnownHosts

func GenerateKnownHosts(host, port, pubkey string) (string, error)

GenerateKnownHosts returns a string that can be added to the user or system known_hosts file. The returned string does not end with a line break.

func GenerateMatchBlock

func GenerateMatchBlock() string

func GetAgent

func GetAgent() (agent.ExtendedAgent, error)

Types

type FilePaths

type FilePaths struct {
	User   string
	System string
}

func PathsHosts

func PathsHosts() (FilePaths, error)

pathsHosts returns the user and system managed hosts file path.

On Unix or macOS, it returns:

user:   $HOME/.ssh/oinit_hosts
system: /etc/ssh/oinit_hosts

On Windows, it returns:

user:   %userprofile%/.ssh/oinit_hosts
system: %programdata%/ssh/oinit_hosts

func PathsSSHConfig

func PathsSSHConfig() (FilePaths, error)

pathsConfig returns the user and system config file path for OpenSSH.

On Unix or macOS, it returns:

user:   $HOME/.ssh/config
system: /etc/ssh/ssh_config

On Windows, it returns:

user:   %userprofile%/.ssh/config
system: %programdata%/ssh/ssh_config

func PathsSSHKnownHosts

func PathsSSHKnownHosts() (FilePaths, error)

pathsKnownHosts returns the user and system known_hosts file path for OpenSSH.

On Unix or macOS, it returns:

user:   $HOME/.ssh/known_hosts
system: /etc/ssh/ssh_known_hosts

On Windows, it returns:

user:   %userprofile%/.ssh/known_hosts
system: %programdata%/ssh/ssh_known_hosts

Jump to

Keyboard shortcuts

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