Documentation ¶
Index ¶
- Constants
- func NewHostPortAddr(net string, host string, port uint16) net.Addr
- func ParseBase64PublicKey(publicKey string) (ssh.PublicKey, error)
- type AuthMethod
- type Client
- type ConnectFunc
- type ConnectMiddleware
- type ConnectOption
- func Addr(addr net.Addr) ConnectOption
- func Auth(authMethod AuthMethod) ConnectOption
- func HostKey(hostKeyVerifier HostKeyVerifier) ConnectOption
- func HostKeyCallback(callback ssh.HostKeyCallback) ConnectOption
- func Net(netConnectFunc NetConnectFunc) ConnectOption
- func Timeout(timeout time.Duration) ConnectOption
- func User(user string) ConnectOption
- type HostKeyVerifier
- type NetConnectFunc
- type NetConnectMiddleware
Constants ¶
const (
Tcp = "tcp"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthMethod ¶
type AuthMethod func() ([]ssh.AuthMethod, error)
func Agent ¶
func Agent() AuthMethod
func AgentExplicitIdentities ¶
func AgentExplicitIdentities(identities ...string) AuthMethod
func Certificate ¶
func Certificate(cert string, privateKey string) AuthMethod
func Password ¶
func Password(password string) AuthMethod
func PrivateKey ¶
func PrivateKey(privateKey string) AuthMethod
PrivateKey returns an AuthMethod which authenticates using a private key.
type Client ¶
Client is high level ssh client which relies on golang.org/x/crypto/ssh
func New ¶
func New(connectFunc ConnectFunc) *Client
type ConnectFunc ¶
type ConnectFunc func(ctx context.Context) (ssh.Conn, <-chan ssh.NewChannel, <-chan *ssh.Request, error)
func Connect ¶
func Connect(opts ...ConnectOption) ConnectFunc
Connect returns a ConnectFunc which validates the provided ConnectOption when the connection is established.
func ConnectCustom ¶
func ConnectCustom(netConnectFunc NetConnectFunc, addr net.Addr, clientConfig *ssh.ClientConfig) ConnectFunc
ConnectCustom returns a ConnectFunc to a remote net.Addr using a connection method NetConnectFunc. The underlying ssh client is configured in ssh.ClientConfig. ConnectCustom allows for the highest d be used when more convenient ConnectFunc factory functions cannot be applied
func Prepare ¶
func Prepare(opts ...ConnectOption) (ConnectFunc, error)
Prepare returns a ConnectFunc and validates the provided ConnectOption immediately
type ConnectMiddleware ¶
type ConnectMiddleware func(ConnectFunc) ConnectFunc
func CircuitBreak ¶
func CircuitBreak() ConnectMiddleware
CircuitBreak wraps a ConnectFunc and ensures that the ConnectFunc will not be called again when a previous call returned an error. If the ConnectFunc has returned an error previously, CircuitBreak will not call it again and return the same error.
func Retry ¶
func Retry(backoff retry.Backoff) ConnectMiddleware
Retry wraps a NetConnectFunc and attempts retries according to the provided retry.Backoff
type ConnectOption ¶
type ConnectOption func(*connectArgs) error
func Addr ¶
func Addr(addr net.Addr) ConnectOption
func Auth ¶
func Auth(authMethod AuthMethod) ConnectOption
func HostKey ¶
func HostKey(hostKeyVerifier HostKeyVerifier) ConnectOption
func HostKeyCallback ¶
func HostKeyCallback(callback ssh.HostKeyCallback) ConnectOption
func Net ¶
func Net(netConnectFunc NetConnectFunc) ConnectOption
func Timeout ¶
func Timeout(timeout time.Duration) ConnectOption
func User ¶
func User(user string) ConnectOption
type HostKeyVerifier ¶
type HostKeyVerifier func() (ssh.HostKeyCallback, error)
func StaticHostKey ¶
func StaticHostKey(publicKey string) HostKeyVerifier
StaticHostKey returns an ssh.HostKeyCallback which accepts only the provided public key. StaticHostKey expects a base64 encoded public key which is parsed using ssh.ParsePublicKey. StaticHostKey uses ssh.FixedHostKey with the decoded public key. Use ssh.FixedHostKey instead of StaticHostKey if an ssh.PublicKey is already available.
type NetConnectFunc ¶
type NetConnectMiddleware ¶
type NetConnectMiddleware func(NetConnectFunc) NetConnectFunc
func NetCircuitBreaker ¶
func NetCircuitBreaker() NetConnectMiddleware
NetCircuitBreaker wraps a NetConnectFunc and ensures that the NetConnectFunc will not be called again when a previous call returned an error. If the NetConnectFunc has returned an error previously, NetCircuitBreaker will not call it again and return the same error.
func NetRetry ¶
func NetRetry(backoff retry.Backoff) NetConnectMiddleware
NetRetry wraps a NetConnectFunc and attempts retries according to the provided retry.Backoff