SFTP Host Keys

An SFTP Host Key is a cryptographic key used to verify the identity of the server during an SFTP connection. This allows the client to be sure that it is connecting to the intended server, preventing man-in-the-middle attacks and ensuring secure communication between the client and Files.com.

Files.com allows you to provide custom SFTP Host Keys, which is particularly useful when migrating to Files.com from an existing SFTP server, allowing the Files.com platform to match your previously-installed host key for a seamless transition.

List SFTP Host Keys

SDK Method

sftphostkey.List()

Return Object

[]*SftpHostKey

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    sftp_host_key "github.com/Files-com/files-sdk-go/v3/sftphostkey"
)

sftpHostKeyIterator, err := sftp_host_key.List(files_sdk.SftpHostKeyListParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for sftpHostKeyIterator.Next() {
    sftpHostKey := sftpHostKeyIterator.sftpHostKey()
}
err = sftpHostKeyIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Show SFTP Host Key

SDK Method

sftphostkey.Find()

Return Object

SftpHostKey

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

SftpHostKeyFindParams Fields

FieldDescription
Id
int64
Required
Sftp Host Key ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    sftp_host_key "github.com/Files-com/files-sdk-go/v3/sftphostkey"
)

sftpHostKey, err := sftp_host_key.Find(files_sdk.SftpHostKeyFindParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Create SFTP Host Key

SDK Method

sftphostkey.Create()

Return Object

SftpHostKey

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

SftpHostKeyCreateParams Fields

FieldDefaultDescription
Active
boolean
falseIf true, use this SFTP Host Key.
Name
string
The friendly name of this SFTP Host Key.
PrivateKey
string
The private key data.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    sftp_host_key "github.com/Files-com/files-sdk-go/v3/sftphostkey"
)

sftpHostKey, err := sftp_host_key.Create(files_sdk.SftpHostKeyCreateParams{Active: lib.Bool(true)})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Update SFTP Host Key

SDK Method

sftphostkey.Update()

Return Object

SftpHostKey

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

SftpHostKeyUpdateParams Fields

FieldDescription
Id
int64
Required
Sftp Host Key ID.
Active
boolean
If true, use this SFTP Host Key.
Name
string
The friendly name of this SFTP Host Key.
PrivateKey
string
The private key data.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    sftp_host_key "github.com/Files-com/files-sdk-go/v3/sftphostkey"
)

sftpHostKey, err := sftp_host_key.Update(files_sdk.SftpHostKeyUpdateParams{
  Id: 1,
  Active: lib.Bool(true)
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

Delete SFTP Host Key

SDK Method

sftphostkey.Delete()

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

SftpHostKeyDeleteParams Fields

FieldDescription
Id
int64
Required
Sftp Host Key ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    sftp_host_key "github.com/Files-com/files-sdk-go/v3/sftphostkey"
)

err := sftp_host_key.Delete(files_sdk.SftpHostKeyDeleteParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

The SftpHostKey Object

Some of the methods above return a SftpHostKey object. The attributes of this object are listed below.

AttributeDescription
Active
boolean
If true, use this SFTP Host Key.
Id
int64
SFTP Host Key ID
Name
string
The friendly name of this SFTP Host Key.
KeyType
string
SSH key type
FingerprintMd5
string
MD5 Fingerprint of the public key
FingerprintSha256
string
SHA256 Fingerprint of the public key