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

@@ -186,4 +186,26 @@ message SshPrivateKeyCredential {
// It must be set.
// @inject_tag: `gorm:"not_null"`
string key_id = 12;
// private_key_passphrase is the plain-text of the passphrase of the SSH private
// key associated with the credential. We are not storing this plain-text
// private key passphrase in the database.
// @inject_tag: `gorm:"-"`
bytes private_key_passphrase = 13 [(custom_options.v1.mask_mapping) = {
this: "PrivateKeyPassphrase"
that: "attributes.private_key_passphrase"
}];
// private_key_passphrase_encrypted is the ciphertext of the private key passphrase. It is stored in
// the database.
// @inject_tag: `gorm:"column:private_key_passphrase_encrypted;not_null"`
bytes private_key_passphrase_encrypted = 14;
// private_key_passphrase_hmac is a sha256-hmac of the unencrypted private key passphrase. It is recalculated
// everytime the private key passphrase is updated.
// @inject_tag: `gorm:"not_null"`
bytes private_key_passphrase_hmac = 15 [(custom_options.v1.mask_mapping) = {
this: "PrivateKeyPassphraseHmac"
that: "attributes.private_key_passphrase_hmac"
}];
}
@@ -376,4 +376,15 @@ message SshPrivateKeyOverride {
//
// @inject_tag: `gorm:"default:null"`
string private_key_attribute = 3;
// private_key_passphrase_attribute is the name of the attribute in the Data
// field of a Vault api.Secret that maps to a private key passphrase. If set,
// it overrides any default attribute names the system uses to find a
// private_key_passphrase attribute.
//
// See
// https://github.com/hashicorp/vault/blob/5e505ec039177e8212cbbab74ccb644c46e62e63/api/secret.go#L25
//
// @inject_tag: `gorm:"default:null"`
string private_key_passphrase_attribute = 4;
}