Vulnerability

SSH Misconfiguration (Port 22)
detect, fix, and prevent regression

Internet-facing Secure Shell on TCP 22 with permissive root login, password authentication, legacy ciphers, or unpatched OpenSSH builds is one of the most consistently exploited initial access vectors in cloud, Linux, network appliance, OT, and IoT estates. Learn how to detect SSH exposure and weak configuration, harden it, and keep the closure verifiable.

No credit card required. Free plan available forever.

Severity

High

CWE ID

CWE-1327

OWASP Top 10

A05:2021 - Security Misconfiguration

CVSS 3.1 Score

9.8

What is SSH misconfiguration?

SSH misconfiguration covers the cluster of weaknesses that turn a Secure Shell service into a credible initial-access path. The most common shape is an internet-facing listener on TCP port 22 that accepts password authentication, permits direct root login, advertises a vulnerable OpenSSH or Dropbear build, negotiates legacy ciphers and key exchange algorithms, or leaves agent and X11 forwarding open by default. Internal-only listeners are not safe by definition either, because lateral movement, internal phishing, and supply-chain compromise of CI runners all read the same misconfigurations as a public attacker would.

Internet-exposed SSH sits inside almost every cloud estate, every Linux fleet, every managed network appliance, every OT and IoT deployment, and every Git over SSH workflow. Joint advisories from CISA, the FBI, the UK NCSC, and ENISA repeatedly cite exposed remote administration services, alongside exposed RDP and exposed SMB, as a leading enabler of ransomware deployment, cryptomining, and intellectual-property theft. The 2024 regreSSHion advisory (CVE-2024-6387) and the 2023 Terrapin attack (CVE-2023-48795) are recent reminders that SSH is not a finished, hardened protocol that can be ignored once it is configured; it is a live service that drifts as builds age, ciphers fall out of consensus, and cloud security groups quietly widen.

The impact tracks the operating context of the exposed host. A jump server reaching the production VPN is a different blast radius from a developer laptop or a tester sandbox. Even where the host itself is unimportant, SSH exposure leads to credential harvesting through default credentials or guessed passwords, followed by privilege escalation on the foothold, lateral movement through SSH key reuse, and pivot into deployment pipelines, secret stores, and source-code repositories.

SSH misconfiguration is also a recurring audit and cyber-insurance finding. PCI DSS Requirement 2.2 and 8.3, ISO 27001 Annex A.8.20 and A.8.21, the CIS Distribution Independent Linux Benchmark Section 5.2, NIST 800-53 SC-7 and AC-17, and most carrier security questionnaires either prohibit or restrict direct internet exposure of remote administration services and require documented hardening of those that remain. Closing the exposure or hardening the listener is usually inexpensive compared to the operational and compliance cost of leaving it open, which is why this class of finding tends to move quickly through remediation tracking once it is surfaced on a controlled record.

How attackers exploit it

1

Discover open 22

Attackers continuously scan IPv4 (Shodan, Censys, Masscan, custom scanners) for hosts answering on TCP 22. The SSH banner is offered on connect, so a single probe reveals the OpenSSH version, the Dropbear build, the vendor SSH stack, and often a hint about the underlying operating system.

2

Brute-force or stuff credentials

Automated tooling (Hydra, Medusa, Patator, ncrack, custom Go runners) attempts common usernames (root, admin, user, ubuntu, ec2-user, deploy, git, oracle) with weak or leaked passwords. Credential stuffing replays passwords from public breach corpora against services that still accept password authentication.

3

Exploit protocol or build weaknesses

Where the host advertises a vulnerable OpenSSH or Dropbear build, attackers run known SSH CVEs (regreSSHion CVE-2024-6387 race condition in sshd, Terrapin CVE-2023-48795 prefix truncation in ChaCha20-Poly1305 and Encrypt-then-MAC, libssh CVE-2018-10933 authentication bypass on the server side) and harvest credentials offered in plaintext over legacy ciphers.

4

Establish foothold and pivot

Once authenticated, attackers harvest authorized_keys and known_hosts, abuse SSH agent forwarding to reach further hosts under the same session, scan for reusable private keys in /home and developer laptops, enumerate CI/CD runner identities, pivot into source-code repositories over Git SSH, and stage ransomware deployment or large-scale data exfiltration.

Common causes

Cloud security group rule too broad

An AWS security group, Azure NSG, or GCP firewall rule opens TCP 22 to 0.0.0.0/0 during a Terraform run, a debug session, a vendor handoff, or a recovery exercise. The rule is never narrowed, and a public SSH listener persists across image rebuilds, autoscaling events, and account migrations.

Password authentication and root login left on

PasswordAuthentication remains yes and PermitRootLogin remains yes (or the more permissive prohibit-password is set on an image that still ships a password-using root account). Brute-force protection sits at the network layer or in fail2ban only, not at the protocol layer through key-only enforcement.

Legacy ciphers, MACs, and KEX in use

sshd_config still advertises hmac-md5, hmac-sha1, arcfour, blowfish, 3des-cbc, diffie-hellman-group1-sha1, or diffie-hellman-group14-sha1 because removing them broke a legacy client years ago. SSH protocol 1 may even remain enabled on archaic builds. The current ssh-audit and NCSC guidance treat the legacy set as a finding by default.

Aged or unpatched OpenSSH and Dropbear builds

Long-lived virtual machines, containers built from frozen base images, IoT firmware, OT switches, network appliances, and home-grown CI agents run an OpenSSH or Dropbear release several years behind the upstream support window. regreSSHion (CVE-2024-6387) and Terrapin (CVE-2023-48795) are recent examples that turn aged builds into immediate exposure events.

Agent, X11, and TCP forwarding left default

AllowAgentForwarding yes, X11Forwarding yes, and AllowTcpForwarding yes are inherited from a stock distro config. An attacker who lands a single session can hop to internal hosts through the developer's forwarded agent, tunnel deeper through the SSH connection, or read X11 windows on the originating workstation.

Host key reuse and missing rotation

Cloned virtual machines and container base images share the same SSH host key, breaking the host-key trust model and enabling man-in-the-middle attacks across the fleet. Host keys are never rotated after suspected compromise or key-material exposure through accidental backup, snapshot, or repository commit.

How to detect it

Automated detection

  • SecPortal's external scanner port-scan module probes TCP 22 across every verified domain and host in scope, captures the SSH banner (OpenSSH or Dropbear with version where the host advertises it), and raises a finding with the recommendation to restrict source IPs, disable password authentication, and patch the build.
  • Continuous monitoring re-runs the external scan on a schedule, so a security-group edit, a Terraform apply, an autoscale event, or a recovered host that re-exposes 22 reopens the finding rather than leaving the regression invisible until the next manual review or audit cycle.
  • Bulk import accepts Nessus, Burp, and CSV output from network-tier scanners and from ssh-audit or sslyze runs that already report weak ciphers, legacy KEX, vulnerable OpenSSH versions, and missing key-only enforcement, so the catalogue stays centralised even when a third-party tool is the original discovery source.

Manual verification

  • Use nmap -p 22 with service detection (-sV) and the ssh2-enum-algos and ssh-hostkey scripts against the external range to confirm the listener, the OpenSSH or Dropbear build, the offered KEX and cipher and MAC sets, and the host key set advertised on each port.
  • Run ssh-audit against each reachable listener to read the policy summary (acceptable, deprecated, weak), check whether the host accepts known-weak algorithms, and produce a per-host hardening recommendation that mirrors the upstream Mozilla and NCSC guidance.
  • Cross-reference the OpenSSH version banner against the CISA Known Exploited Vulnerabilities catalog, the OpenSSH security advisory page, and the vendor advisory feed to identify whether regreSSHion (CVE-2024-6387), Terrapin (CVE-2023-48795), or any other unpatched SSH CVE is present.
  • Check Shodan and Censys for the organisation's netblocks and known hostnames to see whether external observatories already list exposed SSH services and the banners they advertise, then reconcile that list against the verified-domain inventory inside the workspace.

How to fix it

Remove direct internet exposure where possible

Block TCP 22 inbound at the perimeter firewall, the cloud security group, and the load balancer for every host that does not need to be reachable from the public internet. Reach the host through a managed bastion (AWS Systems Manager Session Manager, Azure Bastion, GCP Identity-Aware Proxy, Tailscale, Cloudflare Access, an enterprise jump host, or an enterprise VPN). The default posture for a long-lived workload should be no public SSH listener.

Disable password authentication and root login

Set PasswordAuthentication no, ChallengeResponseAuthentication no, KbdInteractiveAuthentication no, PermitRootLogin no (or prohibit-password where root must remain reachable for emergency recovery), PermitEmptyPasswords no, and UsePAM yes with a PAM policy that does not silently downgrade to password. Authenticate human and machine sessions with hardware-backed keys or short-lived SSH certificates.

Restrict ciphers, MACs, and key exchange to the modern set

Set Ciphers, MACs, KexAlgorithms, and HostKeyAlgorithms to the current Mozilla intermediate or modern set (curve25519-sha256, diffie-hellman-group16-sha512, aes256-gcm@openssh.com, chacha20-poly1305@openssh.com, hmac-sha2-512-etm@openssh.com, ssh-ed25519, rsa-sha2-512). Remove legacy entries and confirm the negotiation with a fresh ssh-audit run after each change.

Patch the SSH build and rotate host keys

Apply OpenSSH and Dropbear updates promptly, especially advisories naming regreSSHion (CVE-2024-6387), Terrapin (CVE-2023-48795), libssh (CVE-2018-10933), the 2023 ssh-agent forwarding CVEs, and the 2022 OpenSSH double-free class. Rotate host keys after a suspected exposure event or after a base-image clone, and replace ssh-rsa with ssh-ed25519 or modern rsa-sha2 keys where the client population supports it.

Lock down forwarding and tunnelling features

Set AllowAgentForwarding no, X11Forwarding no, AllowTcpForwarding no, GatewayPorts no, and PermitTunnel no on hosts that do not need them. Where developer ergonomics require agent forwarding, gate it behind a Match block that names the principal, the source network, or the role, and pair it with confirmation prompts on the workstation through ssh-agent confirm.

Front SSH access with identity-aware authorisation

Replace standing user accounts with short-lived SSH certificates signed by an internal certificate authority (HashiCorp Vault SSH backend, AWS IAM SSH user federation, Smallstep, Teleport, BastionZero, Tailscale SSH). Bind each certificate to a named principal, a maximum lifetime in the order of hours, a source-IP constraint, and the role bundle the principal is authorised to assume on the destination host.

Add monitoring and rate limiting at the protocol layer

Configure LoginGraceTime, MaxAuthTries, MaxSessions, and MaxStartups inside sshd_config. Forward sshd journald or syslog events to the SIEM or detection pipeline. Pair the listener with fail2ban or CrowdSec where direct exposure remains. Track the SSH session catalogue alongside other authentication evidence so the security operations team sees brute-force activity before it succeeds.

Operationalising the fix on the workspace

Closing exposed SSH and hardening sshd_config is rarely the hard part for an experienced platform engineer. The operational hard part is keeping the closure intact across rebuilds, autoscaling, Terraform applies, mergers and acquisitions, vendor migrations, and the long tail of cloud accounts and on-premise hosts that nobody currently lists in a primary asset inventory. The workspace pattern below is what AppSec, cloud security, vulnerability management, and security engineering teams use to keep an SSH-misconfiguration finding from coming back six months later under a new account or a renamed host.

Surface every listener on one finding record

External scanning and bulk import land every exposed-SSH detection on the findings management record with CVSS, the discovered host, the captured banner, the scan timestamp, and the named owner so the catalogue is a single source of truth rather than a Shodan tab, a spreadsheet, and a Slack thread.

Capture configuration drift through authenticated scans

Where the team already has authorisation, the authenticated scanning path reads the responding service in more detail and pairs the result with the per-host hardening record. Credentials for authenticated runs live in encrypted credential storage scoped to a verified domain so the same secret is not copied across spreadsheets and chat threads.

Run remediation as a tracked workflow

Each finding flows through the remediation tracking workflow with severity, target close date, named owner, and the agreed compensating control (for example, an inbound source allowlist while the bastion migration completes, or a temporary fail2ban rule while a certificate authority is stood up). Permanent exceptions enter the eight-field exception register with a named approver, a rationale, an effective period, and a renewal cadence.

Verify the fix with retest

Once the firewall rule, security-group edit, sshd_config change, host retirement, or bastion migration completes, the retesting workflow re-runs the external scan, confirms the listener is gone or that the banner now advertises a patched build with the modern algorithm set, and stamps the closure with timestamped evidence rather than a verbal sign-off.

Catch regressions through continuous monitoring

Scheduled continuous monitoring re-scans of verified domains reopen the finding if SSH returns to the public internet, if the banner drops back to a vulnerable build, or if a new cloud account joins the estate with an open 22. A Terraform apply, an autoscaler refresh, or a recovered backup image does not silently reintroduce the exposure.

Pair with the broader exposure catalogue

Exposed SSH rarely shows up alone. The same host frequently exposes exposed RDP, exposed SMB, default credentials, or TLS or SSL misconfiguration. On the data-service side of the same host, an exposed MongoDB listener or an exposed Elasticsearch cluster is the most common companion finding. On the container-runtime side of the same host, an exposed Docker socket on TCP 2375 or a mounted /var/run/docker.sock inside a CI runner gives an attacker who already has the SSH foothold root-equivalent control of every container on the host. Treating SSH exposure as one finding inside a host-level posture review keeps the queue ordered against real residual risk rather than chasing isolated ports one at a time.

Carry the audit trail through closure

The activity log records who opened, scoped, remediated, and verified each SSH-misconfiguration finding, so the next ISO 27001, SOC 2, PCI DSS, CIS Benchmark review, or cyber insurance renewal reads the operating evidence from the record rather than from reconstructed memory, archived ticket exports, or screenshots taken weeks after the fact.

Communicate posture in leadership language

When SSH posture sits inside a broader programme review, the Claude-drafted AI report composes a leadership-ready narrative from the open and closed findings, the remediation cadence, and the linked compliance evidence. The same record drives security leadership reporting without rebuilding the slide deck by hand each quarter.

Where the misconfiguration usually lands

SSH misconfiguration is not a single shape across the enterprise estate. The conversation a cloud security team has with a platform team about an exposed jump host differs from the conversation an OT security team has with an industrial control vendor whose appliances ship with a default SSH password. The four contexts below are the most common landing places, and each one needs a slightly different remediation playbook surfaced on the same finding record.

Cloud workloads and bastion hosts

Bastion hosts, jump servers, ad-hoc EC2 and Compute Engine instances, and short-lived debug hosts make up the bulk of cloud SSH exposure. Replace standing 0.0.0.0/0 rules with managed bastion services, identity-aware proxies, or zero-trust access brokers. Use short-lived SSH certificates instead of long-lived authorized_keys files. Pair the workspace with the cloud-security review described in /use-cases/cloud-security-assessment.

Network appliances and OT devices

Switches, routers, load balancers, firewalls, NAS appliances, and OT control gateways ship with SSH on by default and frequently with vendor default credentials. Coordinate the hardening with the appliance vendor, capture the firmware build on the finding, and confirm the closure against the cleared CISA KEV catalogue entry where applicable.

IoT and consumer-grade Linux

Long-lived IoT firmware, home-grown Linux builds, and developer-built CI runners frequently ship Dropbear SSH with weak defaults, legacy ciphers, and unpatched libraries. Track these hosts on the finding record with the firmware identifier, the maintainer contact, and the upgrade path. Where the device cannot be patched, isolate it behind a managed network access boundary and document the residual risk decision in the exception register.

Git over SSH and CI runners

SSH is the trust boundary for source-code repository access and for self-hosted runner registration. Compromise of a developer key, a runner identity, or an unrotated deploy key reaches the source code, the deployment pipeline, and the secret store. Pair SSH posture with the developer-workstation key inventory, the platform-side key audit, and the runner rotation cadence so the workspace covers the human, the runner, and the host.

Compliance impact

Where SSH posture lands inside the team

SSH misconfiguration sits across several teams at once. The internal security team owns the policy and the audit response. The cloud security team owns the cloud-account perimeter and bastion architecture. The vulnerability management team owns the backlog, the prioritisation, and the SLA. The security engineering team owns the hardening tooling and the certificate authority. SecPortal keeps the same finding visible to all of them on the workspace record so the handoffs do not lose context as the work moves between owners.

Find every exposed and weakly configured SSH listener across your estate

SecPortal's external scanner probes TCP 22 across verified domains, captures the OpenSSH or Dropbear version banner, raises a high-severity finding with the recommended hardening, tracks remediation, verifies the fix through retest, and re-runs continuously so a cloud security-group edit, a Terraform apply, or a recovered host does not silently re-expose the listener. Start free.

No credit card required. Free plan available forever.