Documentation
¶
Index ¶
- Constants
- Variables
- func CommonOpts(ctx context.Context, sshExe SSHExe, useDotSSH bool) ([]string, error)
- func DetectOpenSSHVersion(ctx context.Context, sshExe SSHExe) semver.Version
- func DisableControlMasterOptsFromSSHArgs(sshArgs []string) []string
- func Format(w io.Writer, sshPath, instName string, format FormatT, opts []string) error
- func IsControlMasterExisting(instDir string) bool
- func IsControlMasterRunning(ctx context.Context, instDir string) bool
- func IsSSHCygwin(sshExe SSHExe) bool
- func ParseOpenSSHVersion(version []byte) *semver.Version
- func PathForSSH(ctx context.Context, sshExe SSHExe, orig string) (string, error)
- func RemoveStaleControlMaster(ctx context.Context, instDir string) (bool, error)
- func SSHArgsFromOpts(opts []string) []string
- func SSHOpts(ctx context.Context, sshExe SSHExe, instDir, username string, ...) ([]string, error)
- func SSHOptsRemovingControlPath(opts []string) []string
- func SftpServerForSSH(ctx context.Context, sshExe SSHExe) string
- type FormatT
- type PubKey
- type SSHExe
Constants ¶
const ( // FormatCmd prints the full ssh command line. // // ssh -o IdentityFile="/Users/example/.lima/_config/user" -o User=example -o Hostname=127.0.0.1 -o Port=60022 lima-default FormatCmd = FormatT("cmd") // FormatArgs is similar to FormatCmd but omits "ssh" and the destination address. // // -o IdentityFile="/Users/example/.lima/_config/user" -o User=example -o Hostname=127.0.0.1 -o Port=60022 FormatArgs = FormatT("args") // FormatOptions prints the ssh option key value pairs. // // IdentityFile="/Users/example/.lima/_config/user" // User=example // Hostname=127.0.0.1 // Port=60022 FormatOptions = FormatT("options") // FormatConfig uses the ~/.ssh/config format // // Host lima-default // IdentityFile "/Users/example/.lima/_config/user " // User example // Hostname 127.0.0.1 // Port 60022 FormatConfig = FormatT("config") )
const EnvShellSSH = "SSH"
Environment variable that allows configuring the command (alias) to execute in place of the 'ssh' executable.
Variables ¶
var Formats = []FormatT{FormatCmd, FormatArgs, FormatOptions, FormatConfig}
Formats is the list of the supported formats.
Functions ¶
func CommonOpts ¶
CommonOpts returns ssh option key-value pairs like {"IdentityFile=/path/to/id_foo"}. The result may contain different values with the same key.
The result always contains the IdentityFile option. The result never contains the Port option.
func DetectOpenSSHVersion ¶
func DisableControlMasterOptsFromSSHArgs ¶
DisableControlMasterOptsFromSSHArgs returns ssh args that disable ControlMaster, ControlPath, and ControlPersist.
func IsControlMasterExisting ¶
IsControlMasterExisting returns true if the control socket file exists.
func IsControlMasterRunning ¶ added in v2.2.0
IsControlMasterRunning reports whether an SSH ControlMaster process is actively listening on the instance's control socket. Unlike IsControlMasterExisting, which only checks that the socket file is present, this dials the socket to verify that a master is alive. A stale socket left behind by an unclean master exit (kill -9, OOM, host crash, or the Cygwin emulation file outliving its process) has no listener and returns false.
func IsSSHCygwin ¶ added in v2.2.0
IsSSHCygwin reports whether sshExe is a Cygwin-based OpenSSH (Git for Windows, MSYS2, Cygwin) rather than native Windows OpenSSH; always false on non-Windows. See cygpathForSSH for the detection and caching.
func ParseOpenSSHVersion ¶
func PathForSSH ¶ added in v2.2.0
PathForSSH converts orig to the path form Lima's ssh-family invocations expect; unchanged on non-Windows. On Windows, Cygwin-based ssh (Git for Windows, MSYS2) gets a /c/Users/... form from the sibling cygpath, which respects the toolchain's fstab; native Windows OpenSSH gets forward slashes (C:/Users/...), which native ssh, ssh-keygen, and scp accept.
func RemoveStaleControlMaster ¶ added in v2.2.0
RemoveStaleControlMaster removes the SSH control socket only when no master process is listening on it. It returns true when a stale socket was removed. A live master's socket is never touched (returns false), and a missing socket is treated as a no-op (returns false). This lets callers recover from a wedged session without clobbering a healthy ControlMaster.
func SSHArgsFromOpts ¶
SSHArgsFromOpts returns ssh args from opts. The result always contains {"-F", "/dev/null} in addition to {"-o", "KEY=VALUE", ...}.
func SSHOpts ¶
func SSHOpts(ctx context.Context, sshExe SSHExe, instDir, username string, useDotSSH, forwardAgent, forwardX11, forwardX11Trusted bool) ([]string, error)
SSHOpts adds the following options to CommonOptions: User, ControlMaster, ControlPath, ControlPersist.
func SSHOptsRemovingControlPath ¶
SSHOptsRemovingControlPath removes ControlMaster, ControlPath, and ControlPersist options from SSH options.
func SftpServerForSSH ¶ added in v2.2.0
SftpServerForSSH returns the path of sftp-server binary from sshExe's toolchain, so a locally-spawned sftp-server (reverse-sshfs) uses the same path form PathForSSH produces. For Cygwin-based ssh the sibling cygpath resolves /usr/lib/ssh/sftp-server; for native OpenSSH it is sftp-server.exe beside ssh.exe. Returns "" on non-Windows, empty input, or no match, leaving the caller to fall back to its library's auto-detection.
Types ¶
type PubKey ¶
func DefaultPubKeys ¶
DefaultPubKeys returns the public key from $LIMA_HOME/_config/user.pub. The key will be created if it does not yet exist.
When loadDotSSH is true, ~/.ssh/*.pub will be appended to make the VM accessible without specifying an identity explicitly.