# WithHostKeyFile

- Module: [CommunityToolkit.Aspire.Hosting.Sftp](/reference/api/go/communitytoolkit.aspire.hosting.sftp.md)
- Version: `13.6.1`
- Kind: `method`
- Defined on: [`SftpContainerResource`](/reference/api/go/communitytoolkit.aspire.hosting.sftp/sftpcontainerresource.md)
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/d9c2addac6f527ef2e33712d290b84574b455a3b)

Adds a bind mount for the specified host key file to an SFTP container resource.

## Remarks

Add an SFTP container to the application model with the host key in the specified file.
```
var builder = DistributedApplication.CreateBuilder(args);
builder.AddSftp("sftp").WithHostKeyFile("./etc/ssh/ssh_host_ed25519_key", KeyType.Ed25519);
builder.Build().Run();
```

## Definition

```go
func (SftpContainerResource) WithHostKeyFile(
    keyFile string,
    keyType KeyType,
) SftpContainerResource
```

## Parameters

- `keyFile` (`string`) -- The path to the host key file.
- `keyType` ([`KeyType`](/reference/api/go/communitytoolkit.aspire.hosting.sftp/keytype.md)) -- The type of the host key.

## Returns

[`SftpContainerResource`](/reference/api/go/communitytoolkit.aspire.hosting.sftp/sftpcontainerresource.md) -- The `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`SftpContainerResource`](/reference/api/go/communitytoolkit.aspire.hosting.sftp/sftpcontainerresource.md)
