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 Function

SftpHostKey.list()

Return Object

ListIterator<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 com.files.ListIterator;
import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.SftpHostKey;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  ListIterator<SftpHostKey> sftpHostKeys = SftpHostKey.list(parameters);
  for (SftpHostKey sftpHostKey : sftpHostKeys.listAutoPaging()) {
    // Operate on sftpHostKey
  }
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Show SFTP Host Key

SDK Function

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.

Function Arguments

ArgumentDescription
id
int64
Required
Sftp Host Key ID.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.SftpHostKey;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  SftpHostKey sftpHostKey = SftpHostKey.find(id, parameters);
  // Operate on sftpHostKey
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Create SFTP Host Key

SDK Function

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.

Function Arguments

ArgumentDefaultDescription
active
boolean
falseIf true, use this SFTP Host Key.
name
string
The friendly name of this SFTP Host Key.
private_key
string
The private key data.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.SftpHostKey;

try {
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("active", true);
  
  SftpHostKey sftpHostKey = SftpHostKey.create(parameters);
  // Operate on sftpHostKey
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Update SFTP Host Key

SDK Function

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.

Attribute Setters

SetterDescription
setActive
boolean
If true, use this SFTP Host Key.
setName
string
The friendly name of this SFTP Host Key.
setPrivateKey
string
The private key data.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.SftpHostKey;

try {
  // Find the sftpHostKey object by its id.
  SftpHostKey sftpHostKey = SftpHostKey.find(id, null);
  HashMap<String, Object> parameters = new HashMap<>();
  parameters.put("active", true);
  sftpHostKey.update(parameters);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

Delete SFTP Host Key

SDK Function

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.

Example Request

import com.files.exceptions.*;
import com.files.exceptions.ApiErrorException.*;
import com.files.models.SftpHostKey;

try {
  // Find the sftpHostKey object by its id.
  SftpHostKey sftpHostKey = SftpHostKey.find(id, null);
  sftpHostKey.delete(null);
} catch (NotAuthenticatedException e) {
  System.out.println("Authentication Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
} catch (SdkException e) {
  System.out.println("Unknown Error Occurred (" + e.getClass().getName() + "): " + e.getMessage());
}

The SftpHostKey Object

Some of the functions 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.
key_type
string
SSH key type
fingerprint_md5
string
MD5 Fingerprint of the public key
fingerprint_sha256
string
SHA256 Fingerprint of the public key