# Enforce SSH host-key policy

Enforce SSH host-key policy on Evotec with practical examples, usage guidance, and reusable project workflows.

Project

Transferetto

Small PowerShell module with FTPS/SFTP functionality

[View on GitHub](https://github.com/EvotecIT/Transferetto) [Visit Website](#) [Releases](https://github.com/EvotecIT/Transferetto/releases/tag/Transferetto-v2.0.0) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/Transferetto)

Stars**93**

Forks**18**

Open issues**0**

PowerShell Gallery downloads**14067470**

Release**v2.0.4**

Language: C# Updated: 2026-11-17

Curated Examples

Use Transferetto to pin host keys, validate known hosts, or use TOFU intentionally.

This pattern is useful when you want SSH automation to be explicit about trust instead of silently accepting a server key.

It is adapted from the source example at `Examples/Example20-SSHHostKeyPolicy.ps1`.

## When to use this pattern

- You are connecting to production or partner systems.
- You need repeatable host-key validation behavior.
- You want a documented path for pinned fingerprints, known-hosts files, or TOFU.

## Example

```powershell
Import-Module Transferetto

$expectedFingerprint = 'SHA256:REPLACE_WITH_SERVER_FINGERPRINT'
$knownHostsPath = Join-Path $env:LOCALAPPDATA 'Transferetto\ssh-known-hosts.tsv'

$sshClient = Connect-SSH -Server 'server.example.com' `
    -Credential (Get-Credential) `
    -ExpectedHostKeyFingerprint $expectedFingerprint `
    -ConnectionTimeoutSeconds 15 `
    -KeepAliveIntervalSeconds 30 `
    -RetryAttempts 2

$sshClient.HostKeyInfo | Format-List
Disconnect-SSH -SshClient $sshClient
```

## Other supported trust models

- `-HostKeyPolicy TrustOnFirstUse -KnownHostsPath $knownHostsPath`
- `-HostKeyPolicy KnownHosts -KnownHostsPath $knownHostsPath`
- `-AcceptAnyHostKey` for disposable test environments only

## What this demonstrates

- connecting with an explicit expected host-key fingerprint
- inspecting the returned host-key metadata on the session
- keeping the trust decision visible in the script instead of implicit

## Source

- [Example20-SSHHostKeyPolicy.ps1](https://github.com/EvotecIT/Transferetto/blob/master/Examples/Example20-SSHHostKeyPolicy.ps1)

<!-- PowerForge markdown artifact sha256:D349AC8B14132E0EC9BD688BAFA4BF3F589DE1D12D62C92B821F051279257176 -->
