askpass

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package askpass provides a backchannel to handle ssh password prompts from the calling instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

func NewUnstartedServer

func NewUnstartedServer(envPrefix string) *Server

NewUnstartedServer creates an unstarted server to handle askpass prompts.

func (*Server) Close

func (s *Server) Close() error

Close stops listening on the unix socket (and removes the file)

func (*Server) IsSubprocess

func (s *Server) IsSubprocess() bool

IsSubprocess returns true if it detects that it was started as a SSH_ASKPASS subprocess. In this case the main program should shutdown immediately (stdout handling already happened before returning).

func (*Server) NewSubprocess

func (s *Server) NewSubprocess(name string) (started func(ppid int), cancel func(), env []string)

NewSubprocess indicates the intent to start a subprocess which might need a password.

  • started must be called with the pid of a parent process of the askpass invocation (to ensure that the password is only given to proper processes)
  • cancel must be called when the subprocess is done
  • env contains the env variables for the askpass override (never nil)

func (*Server) Serve

func (s *Server) Serve(askpass func(name, prompt string, done <-chan struct{}) []byte) error

Serve calls askpass to retrieve the password and give it to askpass (must be called after Server.StartListening) It will return an error only if the unix socket returns an error on ln.Accept.

  • name comes from Server.NewSubprocess
  • prompt is the prompt line provided by askpass
  • done will be closed when the parent process returned (hence the password is no longer needed)

func (*Server) StartListening

func (s *Server) StartListening() error

StartListening starts listening on the unix socket (must be called before Server.Serve)

Jump to

Keyboard shortcuts

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