Public Keys

A PublicKey is used to authenticate to Files.com via SFTP (SSH File Transfer Protocol). This method of authentication allows users to use their private key (which is never shared with Files.com) to authenticate themselves against the PublicKey stored on Files.com.

When a user configures their PublicKey, it allows them to bypass traditional password-based authentication, leveraging the security of key-based authentication instead.

Note that Files.com's SSH support is limited to file operations only. While users can securely transfer files and manage their data via SFTP, they do not have access to a full shell environment for executing arbitrary commands.

When generating new SSH keys, here are the available options: Files.com supports multiple SSH key algorithms: RSA (default 4096 bits, range 1024-4096 in 8-bit increments), DSA (1024 bits only), Ed25519 (256 bits), and ECDSA (256, 384, or 521 bits). When generating keys, the system uses these default lengths unless a specific length is specified.

Files.com also supports importing additional key types that cannot be generated: security key types (sk-ecdsa-sha2-nistp256, sk-ssh-ed25519). RSA keys up to 8192 bits are also supported for import.

Resource Schema

Required

PropertyDescription
title
String
Public key title

Optional

PropertyDescription
user_id
Int64
User ID this public key is associated with
public_key
String
Actual contents of SSH key.
generate_keypair
Bool
If true, generate a new SSH key pair. Can not be used with public_key
generate_private_key_password
String
Password for the private key. Used for the generation of the key. Will be ignored if generate_keypair is false.
generate_algorithm
String
Type of key to generate. One of rsa, dsa, ecdsa, ed25519. Used for the generation of the key. Will be ignored if generate_keypair is false.
generate_length
Int64
Length of key to generate. If algorithm is ecdsa, this is the signature size. Used for the generation of the key. Will be ignored if generate_keypair is false.

Read Only

PropertyDescription
id
Int64
Public key ID
workspace_id
Int64
Workspace ID (0 for default workspace).
created_at
String
Public key created at date/time
expires_at
String
Public key expiration date/time
expired
Bool
Is this public key expired?
fingerprint
String
Public key fingerprint (MD5)
fingerprint_sha256
String
Public key fingerprint (SHA256)
status
String
Only returned when generating keys. Can be invalid, not_generated, generating, complete
Possible values: error, not_set, to_be_generated, generating, complete
last_login_at
String
Key's most recent login time via SFTP
generated_private_key
String
Only returned when generating keys. Private key generated for the user.
generated_public_key
String
Only returned when generating keys. Public key generated for the user.
username
String
Username of the user this public key is associated with

Example Resource

resource "files_public_key" "example_public_key" {
  user_id                       = 1
  title                         = "My Main Key"
  generate_keypair              = false
  generate_private_key_password = "[your private key password]"
  generate_algorithm            = "rsa"
  generate_length               = 4096
}

Resource Import

This Resource supports importing using the following syntax:

Example Import Command

# Public Keys can be imported by specifying the id.
terraform import files_public_key.example_public_key 1

Data Source Schema

Required

PropertyDescription
id
Int64
Public key ID

Read Only

PropertyDescription
workspace_id
Int64
Workspace ID (0 for default workspace).
title
String
Public key title
created_at
String
Public key created at date/time
expires_at
String
Public key expiration date/time
expired
Bool
Is this public key expired?
fingerprint
String
Public key fingerprint (MD5)
fingerprint_sha256
String
Public key fingerprint (SHA256)
status
String
Only returned when generating keys. Can be invalid, not_generated, generating, complete
Possible values: error, not_set, to_be_generated, generating, complete
last_login_at
String
Key's most recent login time via SFTP
generated_private_key
String
Only returned when generating keys. Private key generated for the user.
generated_public_key
String
Only returned when generating keys. Public key generated for the user.
username
String
Username of the user this public key is associated with
user_id
Int64
User ID this public key is associated with

Example Data Source

data "files_public_key" "example_public_key" {
  id = 1
}