---
title: Instances should use instance-specific SSH keys instead of project-wide keys
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Instances should use instance-specific
  SSH keys instead of project-wide keys
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Instances should use instance-specific SSH keys instead of project-wide keys
 
## Description{% #description %}

Block project-wide SSH keys on each Compute Engine instance, or use OS Login, so that a key added to project metadata cannot be used to sign in to every instance in the project.

This rule passes when instance metadata sets `block-project-ssh-keys` to true, or when OS Login is enabled for the instance, because OS Login disables metadata-based SSH keys. OS Login is read from `enable-oslogin` in instance metadata, or from project metadata when the instance does not set a valid value. `block-project-ssh-keys` in project metadata is not counted, because the guest environment only reads it from instance metadata.

OS Login is not counted for a Windows instance that enables Windows SSH, because Windows images do not support OS Login and accept project-wide keys when `enable-windows-ssh` is true. An instance is treated as Windows when its boot disk has the `WINDOWS` guest OS feature or a `windows-cloud` license. Instances without either signal, including Linux instances that inherit `enable-windows-ssh` from project metadata, are treated as non-Windows. Windows SSH is read from `enable-windows-ssh` in instance metadata, or from project metadata when the instance does not set a valid value. A Windows instance with Windows SSH enabled passes only when it blocks project-wide SSH keys.

OS Login is not counted for a Fedora CoreOS instance, which passes only when instance metadata sets `block-project-ssh-keys` to exactly `true`. Fedora CoreOS installs SSH keys with Afterburn instead of the guest environment. Afterburn ignores OS Login and installs project-wide keys, unless `block-project-ssh-keys` is set to the lowercase value `true`. An instance is treated as Fedora CoreOS when its boot disk has a `fedora-coreos-` license, which public Fedora CoreOS images carry. The rule evaluates Fedora CoreOS images built without that license like other Linux images.

On other instances, `enable-oslogin`, `enable-windows-ssh`, and `block-project-ssh-keys` are read the way the guest environment parses them: exactly `1`, `t`, `T`, `true`, `TRUE`, or `True` for true and `0`, `f`, `F`, `false`, `FALSE`, or `False` for false. Other values, such as `Yes` or `TrUe`, are treated as unset.

GKE nodes (name starts with `gke-` and has a non-empty `goog-k8s-cluster-name` label) are skipped, although the CIS benchmark lists no GKE exception for this control. Zonal metadata and the `compute.requireOsLogin` organization policy are not evaluated. OS Login is still counted on other Linux images that Google lists as not supporting it, such as SLES 16 and Ubuntu 14.04, because their guest environment stops installing metadata SSH keys when OS Login is enabled.

## Remediation{% #remediation %}

Do one of the following:

- Set `block-project-ssh-keys` to `true` in the instance metadata, following [Block project SSH keys from VMs](https://docs.cloud.google.com/compute/docs/connect/restrict-ssh-keys#block-keys). Fedora CoreOS accepts only this lowercase value.
- For an instance that is not Windows or Fedora CoreOS, enable OS Login for the project or the instance, following [Set up OS Login](https://docs.cloud.google.com/compute/docs/oslogin/set-up-oslogin).

## References{% #references %}

- [Restrict SSH keys from VMs](https://docs.cloud.google.com/compute/docs/connect/restrict-ssh-keys#block-keys)
- [Set up OS Login](https://docs.cloud.google.com/compute/docs/oslogin/set-up-oslogin)
- [Connect to Windows VMs using SSH](https://docs.cloud.google.com/compute/docs/connect/windows-ssh)
- [Automatically applied labels](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/creating-managing-labels#automatically-applied-labels)
- [Provisioning Fedora CoreOS on Google Cloud Platform](https://docs.fedoraproject.org/en-US/fedora-coreos/provisioning-gcp/)
- [CIS Google Cloud Platform Foundation Benchmark](https://www.cisecurity.org/benchmark/google_cloud_computing_platform)
