ConnectorTypeSFTP
class connector_types.connector_type_sftp.ConnectorTypeSFTP
Copy a file from an SFTP remote host to Cloudomation Engine or vice-versa.
This connector type uses the SFTP protocol to interact with a remote host.
It supports copying files from a remote host to Cloudomation Engine or vice-versa, listing the contents of a remote host, fetching stats for a file or directory, removing a file or directory, copying a directory from a remote host to Cloudomation Engine or vice-versa, renaming a file or directory, creating a directory.
The SFTP protocol should not be confused with FTP. While similar in names, SFTP and FTP use different protocols and offer different ways of transferring files. If you want to use the FTP protocol, refer to ConnectorTypeFTP
For more on the differences between SFTP and FTP refer to Difference between FTP and SFTP
Input Schema
-
schema_version
Type:
string
-
authentication
Type:
anyOf
Options: -
host
The remote hostname or IP address.
Type:
string
-
hostkey
The public key of host.
Type:
anyOf
Options: -
port
Type:
anyOf
Options: -
mode
Type:
anyOf
Options: -
connect_timeout
A timeout for connecting to a peer in seconds.
Type:
integer
Default:
30
Output Schema
Example
SSH key authentication and copying a file from a remote host to Cloudomation Engine
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SFTP',
authentication={
'authentication_method': 'ssh_key',
'username': '...',
'ssh_key': '...',
},
host='...',
hostkey={
'hostkey_mode': 'known_host',
'known_host': '...',
},
mode={
'mode_name': 'copy_file_to_engine',
'source_file_name': '...',
'destination_file_name': '...',
'destination_location': {
'location_mode': 'inherit_from_execution',
},
},
)
return this.success('all done')
Username and password authentication and copying a file from Cloudomation Engine to a remote host
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SFTP',
authentication={
'authentication_method': 'username_password',
'username': '...',
'password': '...',
},
host='...',
port={
'port_mode': 'port_number',
'port_number': 2022, # non-standard port
},
hostkey={
'hostkey_mode': 'known_host',
'known_host': '...',
},
mode={
'mode_name': 'copy_file_from_engine',
'source_file_name': '...',
'destination_file_name': '...',
},
)
return this.success('all done')
Listing the contents of a directory on a remote host
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SFTP',
...,
mode={
'mode_name': 'list',
'path': '...',
},
)
return this.success('all done')
Removing a file from a remote host
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SFTP',
...,
mode={
'mode_name': 'remove',
'path': '...',
},
)
return this.success('all done')
Copy a path on the remote host to another path on the remote host
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
this.connect(
connector_type='SFTP',
...,
mode={
'mode_name': 'copy_path',
'source_path': '...',
'destination_path': '...',
'preserve': False, # Whether or not to preserve the original file attributes.
'recurse': False, # Whether or not to recursively copy directories.
},
)
return this.success('all done')