terraform-provider-onepassword icon indicating copy to clipboard operation
terraform-provider-onepassword copied to clipboard

Return OpenSSH formatted values/attributes for items of type SSH Key

Open dominikmueller opened this issue 7 months ago • 1 comments

Summary

SSH Keys currently return the string value of the private key field. This feels a bit strange since the OP cli and UI would return the keys in OpenSSH format when revealing/copying the private key.

See https://1password.community/discussion/142994/beg-report-ed25519-ssh-private-keys-human-readable-value-differs-from-json-value for more information regarding the difference between the private key value field and the available values from ssh_formats.

Use cases

Consistent/WYSIWYG behaviour between terraform provider resources and UI/op-cli.

Proposed solution

Either always return the openssh formatted key for the private_key attribute or add another attribute that returns the openssh format - e.g. private_key_openssh? Or vice versa (e.g. private_key_pem_pkcs8).

Maybe use the tls providers attributes as a template to keep the resources alligned: https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key#read-only

Is there a workaround to accomplish this today?

Not sure. Feels kind of difficult/unnecessary to manually convert SSH keys in terraform.

References & Prior Work

OP-Cli also returns the OpenSSH format instead of the field value by default.

dominikmueller avatar Jul 18 '24 11:07 dominikmueller