Documentation ¶
Overview ¶
Package credentials describes credentials.
Index ¶
- func GetAgentSocketFromConfig(host string) (string, error)
- func GetDefaultAgentSocket() string
- func GetLogin() string
- func GetPrivateKeysFromConfig(host string) ([][]byte, error)
- func GetUsernameFromConfig(host string) string
- type Credentials
- type CredentialsOption
- func WithLogger(logger *zap.Logger) CredentialsOption
- func WithPassphrase(passphrase Secret) CredentialsOption
- func WithPassword(password Secret) CredentialsOption
- func WithPasswords(password []Secret) CredentialsOption
- func WithPrivateKey(key []byte) CredentialsOption
- func WithPrivateKeys(key [][]byte) CredentialsOption
- func WithSSHAgentSocket(agentSocket string) CredentialsOption
- func WithUsername(username string) CredentialsOption
- type Secret
- type SimpleCredentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAgentSocketFromConfig ¶ added in v1.0.8
GetAgentSocketFromConfig computes SSH authentication agent socket path using default ssh config's IdentityAgent and ForwardAgent keywords. IdentityAgent value supports tilde syntax, but it doesn't support %d, %h, %l and %r.
func GetDefaultAgentSocket ¶ added in v1.0.8
func GetDefaultAgentSocket() string
GetDefaultAgentSocket returns default ssh authentication agent socket (read from SSH_AUTH_SOCK env)
func GetLogin ¶
func GetLogin() string
GetLogin tries to get sudo user from env, falling back to current user
func GetPrivateKeysFromConfig ¶ added in v1.0.8
GetPrivateKeysFromConfig tries to extract PrivateKeys from default config's IdentityFiles specified for provided host. IdentityFile value supports tilde syntax, but it doesn't support %d, %u, %l, %h and %r.
func GetUsernameFromConfig ¶ added in v1.0.8
GetUsernameFromConfig extracts User keyword value for given host from default ssh config.
Types ¶
type Credentials ¶
type CredentialsOption ¶
type CredentialsOption func(*SimpleCredentials)
func WithLogger ¶
func WithLogger(logger *zap.Logger) CredentialsOption
func WithPassphrase ¶
func WithPassphrase(passphrase Secret) CredentialsOption
func WithPassword ¶
func WithPassword(password Secret) CredentialsOption
func WithPasswords ¶
func WithPasswords(password []Secret) CredentialsOption
func WithPrivateKey ¶
func WithPrivateKey(key []byte) CredentialsOption
func WithPrivateKeys ¶ added in v1.0.8
func WithPrivateKeys(key [][]byte) CredentialsOption
func WithSSHAgentSocket ¶ added in v1.0.8
func WithSSHAgentSocket(agentSocket string) CredentialsOption
func WithUsername ¶
func WithUsername(username string) CredentialsOption
type SimpleCredentials ¶
type SimpleCredentials struct {
// contains filtered or unexported fields
}
func NewSimpleCredentials ¶
func NewSimpleCredentials(opts ...CredentialsOption) *SimpleCredentials
func (SimpleCredentials) GetAgentSocket ¶ added in v1.0.8
func (m SimpleCredentials) GetAgentSocket() string
func (SimpleCredentials) GetPassphrase ¶
func (m SimpleCredentials) GetPassphrase() Secret
func (SimpleCredentials) GetPasswords ¶
func (m SimpleCredentials) GetPasswords(ctx context.Context) []Secret
func (SimpleCredentials) GetPrivateKeys ¶ added in v1.0.8
func (m SimpleCredentials) GetPrivateKeys() [][]byte
func (SimpleCredentials) GetUsername ¶
func (m SimpleCredentials) GetUsername() (string, error)