Add support for SSH private key passphrases (#2331)

This adds support for encrypted SSH keys via passphrase.

Co-authored-by: Louis Ruch <louisruch@gmail.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2022-08-08 15:15:03 -04:00
1 parent 07bca9dd66
commit 02dd28f587
45 files changed
+1921 -382

No files matched your search

+24
View File
@@ -134,6 +134,30 @@ func WithSshPrivateKeyCredentialPrivateKey(inPrivateKey string) Option {
}
}
func WithSshPrivateKeyCredentialPrivateKeyPassphrase(inPrivateKeyPassphrase string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["private_key_passphrase"] = inPrivateKeyPassphrase
o.postMap["attributes"] = val
}
}
func DefaultSshPrivateKeyCredentialPrivateKeyPassphrase() Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
}
val := raw.(map[string]interface{})
val["private_key_passphrase"] = nil
o.postMap["attributes"] = val
}
}
func WithSshPrivateKeyCredentialUsername(inUsername string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
@@ -8,9 +8,11 @@ import (
)
type SshPrivateKeyAttributes struct {
Username string `json:"username,omitempty"`
PrivateKey string `json:"private_key,omitempty"`
PrivateKeyHmac string `json:"private_key_hmac,omitempty"`
Username string `json:"username,omitempty"`
PrivateKey string `json:"private_key,omitempty"`
PrivateKeyHmac string `json:"private_key_hmac,omitempty"`
PrivateKeyPassphrase string `json:"private_key_passphrase,omitempty"`
PrivateKeyPassphraseHmac string `json:"private_key_passphrase_hmac,omitempty"`
}
func AttributesMapToSshPrivateKeyAttributes(in map[string]interface{}) (*SshPrivateKeyAttributes, error) {