# WithUserKeyFile

- 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 public key file of the specified user 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").WithUserKeyFile("foo", "./home/foo/.ssh/keys/id_rsa.pub", KeyType.Rsa);
builder.Build().Run();
```

## Definition

```go
func (SftpContainerResource) WithUserKeyFile(
    username string,
    keyFile string,
    keyType KeyType,
) SftpContainerResource
```

## Parameters

- `username` (`string`) -- The user whose public key is being bind mounted
- `keyFile` (`string`) -- The public key file of the specified user (will be bind mounted on the server).
- `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)
