SFTPObjectStore#

class composer.utils.SFTPObjectStore(host, port=22, username=None, password=None, known_hosts_filename=None, known_hosts_filename_environ='COMPOSER_SFTP_KNOWN_HOSTS_FILE', key_filename=None, key_filename_environ='COMPOSER_SFTP_KEY_FILE', missing_host_key_policy='RejectPolicy', cwd='', connect_kwargs=None)[source]#

Utility for uploading to and downloading to a server via SFTP.

Parameters
  • host (str) โ€“

    The server to connect to.

    Also accepts a URI string in the form 'sftp://username@host:port/./relative/path'. For an absolute path, use a double // โ€“ e.g. 'sftp://username@host:port//absolute/path'.

  • port (int, optional) โ€“ The server port to connect to.

  • username (str, optional) โ€“ The username (if not specified in the SSH config) needed to authenticate. Defaults to None.

  • password (str, optional) โ€“ The password (if required) needed to authenticate. Defaults to None.

  • key_filename (Path | str, optional) โ€“ The filepath to the a private key (if required) needed to authenticate. Defaults to None. Any keys specified here will be tried in addition to any keys specified in ~/.ssh/ or via a SSH agent.

  • key_filename_environ (str, optional) โ€“ Environment variable defining path to an SSH keyfile. Only used if key_filename is not provided. Default: COMPOSER_SFTP_KEY_FILE.

  • known_hosts_filename (Path | str, optional) โ€“ The filename of the known hosts file. If not specified, the default SSH known hosts will be used.

  • known_hosts_filename_environ (str, optional) โ€“ Only used if known_hosts_filename is not provided. Default: COMPOSER_SFTP_KNOWN_HOSTS_FILE.

  • missing_host_key_policy (str | paramiko.client.MissingHostKeyPolicy, optional) โ€“

    The class name or instance of paramiko.client.MissingHostKeyPolicy to use for a missing host key. Defaults to 'RejectPolicy'.

    Built-in options: * 'RejectPolicy' (the default), which will reject any host key not authorized in the known_hosts_filename. * 'AutoAddPolicy', which will add any unknown host key. * 'WarningPolicy', which will warn on an unknown host key.

    For custom logic, subclass paramiko.client.MissingHostKeyPolicy, and provide an instance of this class.

  • cwd (str, optional) โ€“ The directory to navigate to upon creating the SSH connection. If not present it will be created.

  • connect_kwargs (Dict[str, Any], optional) โ€“ Any additional kwargs to pass through to SSHClient.connect().