# SftpContainerResource.WithUserKeyFile

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

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
type SftpContainerResource interface {
    // ... omitted for brevity
    WithUserKeyFile(
        username string,
        keyFile string,
        keyType KeyType,
    ) SftpContainerResource
}
```

## Signature

```go
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()`.

## Defined on

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