What is .pub?

.pub files typically contain public cryptographic keys. In SSH, a .pub file stores the public half of an asymmetric key pair, which servers or services use to verify signatures from the corresponding private key. Public keys can be shared broadly and do not need to be kept secret, but they must remain correctly paired with their private counterpart.

This quick guide explains when to use .pub files, how to open them on any device, and how to share them instantly with FileXhost.

When to use .pub files

  • You are configuring SSH access using key-based authentication instead of passwords.
  • You need to distribute a public key so servers or collaborators can verify signatures or grant access.
  • You are working with infrastructure that uses public keys to authenticate clients, services, or deployments.
  • You are documenting or backing up which public keys are authorized for a given environment.

How to open .pub files

PUB files are plain text and can be opened in any editor to inspect the key type and fingerprint (for example, 'ssh-ed25519' or 'ssh-rsa' followed by the Base64-encoded key and an optional comment). Tools like ssh-keygen, OpenSSL, or platform key managers can parse and display details. When you upload PUB files to FileXhost, they can be shared as downloadable artifacts so collaborators or servers can add them to authorized key lists.

Algorithm details

Public keys in PUB files are usually part of asymmetric algorithms such as RSA, ECDSA, or Ed25519. In SSH, the .pub file encodes the key type, length, and coordinates (or modulus/exponent) in a standardized text format. In TLS and PKI, public keys are often embedded inside X.509 certificates rather than stored as standalone PUB files, but the underlying key material follows the same mathematical principles.

Browser & platform support

  • Desktop: Browsers treat PUB files as text or binary downloads; they do not interpret them directly.
  • Mobile: Mobile devices can display PUB files as text but rely on apps or OS features to import keys where needed.
  • OS: Operating systems and tools use public keys to verify signatures and establish trust, often via SSH or certificate infrastructure.

Format comparison

FeatureDetails
PUB vs KEYPUB files contain public keys that can be shared widely; KEY files contain private keys that must remain secret.
PUB vs PEMPEM is a generic text container, while PUB is a specific extension commonly used for SSH public keys; PEM files may contain keys or certificates.
PUB vs CRT/CERCRT/CER files bundle public keys with identity information and signatures in X.509 certificates, whereas PUB files usually hold just the raw public key.
UsagePUB files are most common in SSH workflows, while certificates and PEM containers dominate in TLS/HTTPS.

How to create pub files

  • ssh-keygen: Generate SSH key pairs; the .pub file is created alongside the private key.
  • OpenSSL: Derive and export public keys from existing private key or certificate material.
  • Cloud and DevOps Tools: Some platforms output public keys for use in authorized_keys or IAM configurations.
  • Key Management Systems: Export public keys from centralized key vaults for distribution to services and environments.

How to convert pub files

  • FileXhost: Share PUB files via FileXhost so administrators can download and add them to authorized key lists.
  • ssh-keygen/OpenSSL: Convert between different public key formats or extract public keys from private keys and certificates.
  • Certificate Tools: Export public keys from certificates or keystores into standalone PUB-like formats when needed.
  • Online Tools: Some services can parse and display public key fingerprints from PUB files (only safe because public keys are not secret).

Advantages & disadvantages

Advantages

  • Safe to share publicly, enabling easy distribution of access credentials
  • Compact, text-based format that is simple to inspect and copy
  • Works across SSH and other public key cryptography systems

Disadvantages

  • Must remain correctly paired with the corresponding private key to be useful
  • Mismanaged or outdated PUB files in authorized lists can leave unused access paths
  • Understanding key types and strengths (RSA vs Ed25519, key length) can be confusing for new users

Tools & software

CLI Tools

ssh-keygen, OpenSSH tools, OpenSSL

Servers/Services

OpenSSH server, Git servers, CI/CD systems that use SSH deployment keys

Key Management

Cloud IAM and key management services, enterprise key directories

Frequently asked questions

Is it safe to share a .pub file?

Yes. Public keys are designed to be shared. They allow others to verify signatures or encrypt data for you, but they do not reveal your private key or allow impersonation on their own.

Where is the private key for a .pub file stored?

The private key is typically stored in a corresponding file without the .pub extension (for example, 'id_ed25519' or 'id_rsa') and must be kept secret. The PUB file only contains the public half of the pair.

How do I add my PUB key to a server?

Copy the contents of the .pub file into the server's authorized_keys file or follow the platform's documentation for adding SSH keys. This allows the server to trust authentication attempts from the matching private key.

Can I regenerate a .pub file from a private key?

Yes. Tools like ssh-keygen and OpenSSL can derive the public key from a private key and re-create a PUB-style output, as long as you still have the private key.

Technical specs

File type
Security
Extension
.pub
MIME type
text/plain, application/octet-stream
Compression
Uncompressed
Max file size on FileXhost
Up to 25 MB per file on the free plan and up to 1 GB on Pro FileXhost accounts.

Share .pub files instantly

Upload your .pub file to FileXhost to get a clean, shareable URL in seconds. View the file in a modern browser, protect access with optional settings, and let others download it without any confusing ads or cluttered file pages.

Upload .pub file