Understanding and Implementing SSHFP DNS Records Correctly

Author

Reads 5.7K

Close-up of wooden blocks spelling 'encryption', symbolizing data security and digital protection.
Credit: pexels.com, Close-up of wooden blocks spelling 'encryption', symbolizing data security and digital protection.

SSHFP records are used to provide a secure way to verify the fingerprint of a server's SSH host key. This is crucial for ensuring the authenticity of the server and preventing man-in-the-middle attacks.

SSHFP records are stored in the DNS and contain the fingerprint of the server's SSH host key. This fingerprint is a unique string of characters that identifies the key.

To create an SSHFP record, you need to specify the algorithm and the fingerprint of the server's SSH host key. The algorithm is used to determine how the fingerprint is formatted.

The SSHFP record is then used by SSH clients to verify the identity of the server. If the fingerprint in the SSHFP record matches the fingerprint of the server's SSH host key, the client can establish a secure connection.

What Is a Record?

An SSHFP record is a type of DNS record.

It contains a fingerprint of an SSH server's public key.

Credit: youtube.com, How to add SSHFP record?

This fingerprint is a unique identifier for the server's key.

It enables clients to verify the server's identity during SSH connections.

For example, if you're connecting to 'ssh.example.com', the SSHFP record for that domain would hold the fingerprint of its SSH public key.

This helps ensure that the server you're connecting to is the one you expect.

It adds a layer of trust to your SSH sessions.

Discover more: Dns Records Example

Why You Need a Record?

You need an SSHFP record to enhance the security and efficiency of SSH connections. By using DNSSEC, SSHFP records ensure the authenticity and integrity of DNS responses, protecting against man-in-the-middle attacks.

An SSHFP record simplifies SSH key management by centralizing SSH key fingerprints in DNS, reducing the need for known_hosts files. This reduces the risk of human error and key spoofing by securely matching the server's public key fingerprint.

SSHFP records streamline key updates, making it easy to add or remove keys. This supports efficient key management, especially in dynamic environments.

An SSHFP record is a must-have for transparent and auditable key management, aiding in compliance with security standards and regulations.

See what others are reading: MIME Object Security Services

How to Create and Configure

Credit: youtube.com, How to create SSHFP record in ClouDNS

To create SSHFP records, you'll need to open a free account on a DNS management platform and verify your email address. Then, go to your zone management page and click on "Add new record".

Type: SSHFP, Host: your hostname.net, Algorithm: choose from RSA, DSA, or ECDSA, Fingerprint type: choose from SHA-1 or SHA-256, and Points to: the fingerprint you want to point to.

You can also generate SSHFP records using OpenSSH's built-in tools, such as ssh-keyscan.

Here's a quick rundown of the SSHFP record schema, as defined by RFC 4255:

Remember to enable DNSSEC for your domain and collect the SSHFP records for all your SSH-accessible systems.

How It Works

To create and configure SSHFP records, you need to understand how they work. An SSHFP record contains three important components: Algorithm, Fingerprint Type, and Fingerprint. These components work together to form a unique identifier for the server's public key.

The Algorithm component specifies the type of key used, such as RSA, DSA, or ECDSA. This is represented by a numerical value according to the SSHFP specification. For example, RSA is represented by the numerical value 1.

Focused man working remotely from a garage workshop using a laptop.
Credit: pexels.com, Focused man working remotely from a garage workshop using a laptop.

The Fingerprint Type component specifies the type of hash used to create the fingerprint. This can be SHA-1 or SHA-256, represented by the numerical values 1 and 2 respectively.

The Fingerprint component is the hash of the server's public key, creating a unique identifier for it. This is the core of the SSHFP record, and it's what allows clients to verify the server's identity.

SSHFP records are used by clients to verify the server's identity when establishing a connection. Here's a step-by-step overview of how it works:

  1. The client queries the DNS for the SSHFP record of the server's domain.
  2. The client compares the fingerprint in the DNS record with the fingerprint of the public key presented by the server.
  3. If the fingerprints match, the client can trust the server's identity.
  4. If the fingerprints don't match, the client may warn the user or block the connection, indicating a potential security risk.

To generate SSHFP records, you can use tools like ssh-keygen. For example, running ssh-keygen -r ssh.example.com will output the SSHFP record for the server's public key.

Prerequisites

To create and configure SSHFP records, you'll need to meet some basic prerequisites. To get started, you'll need a Linux VPS running an SSH server. This will serve as the foundation for your SSHFP setup.

You'll also need another Linux computer with the OpenSSH client installed, or another Linux VPS that can connect to your SSH server. This will allow you to test and configure your SSHFP records.

Close-up of network server showing organized cable management and patch panels in a data center.
Credit: pexels.com, Close-up of network server showing organized cable management and patch panels in a data center.

A domain name with DNSSEC set up is also required. DNSSEC allows the SSH client to trust the information stored in DNS records, making it a crucial component of SSHFP records. If you haven't already, enable DNSSEC on your domain name.

Make sure you have A and (optionally) AAAA records pointing to your VPS. These records will direct traffic to your SSH server.

Lastly, ensure that your DNS resolver supports DNSSEC. If it doesn't, you can use a free alternative like Google Public DNS or Cloudflare's 1.1.1.1 service.

Manual and Automated Processes

SSHFP records can be distributed via DNS, removing the need for user interaction and potential human error.

This approach allows administrators to publish host fingerprints as SSHFP records, which can be securely obtained through DNSSEC.

Automating the process of distributing SSHFP records can be done through the use of DNS management tools, making it efficient for larger environments.

By configuring SSH clients to verify SSHFP records, users can ensure overall security is improved and MITM attacks are mitigated.

Manual Process

Computer server in data center room
Credit: pexels.com, Computer server in data center room

The manual process is a traditional approach that requires users to compare the server's host key fingerprint with an out-of-band obtained fingerprint. This often involves contacting the administrator responsible for the server.

This process is prone to human error when comparing fingerprints, which can be a significant risk.

Automated Via DNS

Automated distribution of host key fingerprints via DNS can remove user interaction and potential human error.

This approach uses a special resource record, which can be securely obtained through DNSSEC.

Publishing a host's fingerprints as a set of SSHFP records is all that's required from the administrator.

OpenSSH-client can query the DNS and do the comparison, mitigating MITM attacks and improving overall security.

It only requires the administrator to publish a host’s fingerprints as a set of SSHFP records, which can be securely obtained (DNSSEC).

This method ensures that SSH connections are secure without relying on user interaction or manual configuration.

SSH clients can be configured to verify SSHFP records by adding VerifyHostKeyDNS yes to the SSH configuration.

This allows for a more automated and secure process, reducing the risk of human error.

Understanding SSHFP Records

Credit: youtube.com, DevOps & SysAdmins: SSHFP records on Windows DNS Server (2 Solutions!!)

SSHFP records are a crucial part of securing your SSH connections. They allow clients to verify the identity of the server by comparing the fingerprint in the DNS record with the fingerprint of the public key presented by the server.

The SSHFP record schema is defined in RFC 4255, and it consists of three parts: KEY-ALGO, HASH-TYPE, and fingerprint. KEY-ALGO represents the key's algorithm, and HASH-TYPE defines the used hash algorithm.

Here are the possible values for KEY-ALGO and HASH-TYPE:

To generate SSHFP records, you can use the ssh-keygen command on the server, replacing the example name with your server's Fully-Qualified Domain Name (FQDN). The output will be similar to the example provided.

SSHFP records can be easily generated using OpenSSH's built-in tools, and an update is only required if the host keys change. However, the SSHFP records must reach the client in a secure fashion, otherwise, a man-in-the-middle attack could happen on the DNS instead of the SSH layer.

Generating and Reviewing Records

Credit: youtube.com, Unix & Linux: How do I generate SSHFP records? (5 Solutions!!)

You can generate SSHFP records using the ssh-keyscan command, which is run from the server itself. This is because the records are generated from the SSH server's public key.

The KEY-ALGO is a numeral representing the key's algorithm, with values ranging from 0 (reserved) to 6 (ED448). The HASH-TYPE defines the used hash algorithm, with values 0 (reserved), 1 (SHA1), and 2 (SHA256).

To generate SSHFP records, log on to your VPS and run the ssh-keyscan command, replacing the example name with your server's Fully-Qualified Domain Name (FQDN).

Here's an example of the output you might see:

SSHFP records can also be generated using OpenSSH's built-in tools, making it almost trivial to deploy host key verification fingerprints in the DNS.

To review records, you can use the debug output, which tells you what will happen in the background when OpenSSH establishes a connection to the server, obtains the server-side host key fingerprint, and queries the domain for SSHFP records.

The SSHFP records must reach the client in a secure fashion, otherwise, the MITM could happen on the DNS instead of the SSH layer.

Elaine Block

Junior Assigning Editor

Elaine Block is a seasoned Assigning Editor with a keen eye for detail and a passion for storytelling. With a background in technology and a knack for understanding complex topics, she has successfully guided numerous articles to publication across various categories. Elaine's expertise spans a wide range of subjects, from cutting-edge tech solutions like Nextcloud Configuration to in-depth explorations of emerging trends and innovative ideas.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.