def put(self, local_path, remote_path, mode=None, mirror_local_mode=False):
        """
        Upload a file to the remote node.

        :type local_path: ``st``
        :param local_path: File path on the local node.

        :type remote_path: ``str``
        :param remote_path: File path on the remote node.

        :type mode: ``int``
        :param mode: Permissions mode for the file. E.g. 0744.

        :type mirror_local_mode: ``int``
        :param mirror_local_mode: Should remote file mirror local mode.

        :return: Attributes of the remote file.
        :rtype: :class:`posix.stat_result` or ``None``
        """

        if not local_path or not remote_path:
            raise Exception(
                "Need both local_path and remote_path. local: %s, remote: %s"
                % local_path,
                remote_path,
            )
        local_path = quote_unix(local_path)
        remote_path = quote_unix(remote_path)

        extra = {
            "_local_path": local_path,
            "_remote_path": remote_path,
            "_mode": mode,
            "_mirror_local_mode": mirror_local_mode,
        }
        self.logger.debug("Uploading file", extra=extra)

        if not os.path.exists(local_path):
            raise Exception("Path %s does not exist locally." % local_path)

        rattrs = self.sftp.put(local_path, remote_path)

        if mode or mirror_local_mode:
            local_mode = mode
            if not mode or mirror_local_mode:
                local_mode = os.stat(local_path).st_mode

            # Cast to octal integer in case of string
            if isinstance(local_mode, six.string_types):
                local_mode = int(local_mode, 8)
            local_mode = local_mode & 0o7777
            remote_mode = rattrs.st_mode
            # Only bitshift if we actually got an remote_mode
            if remote_mode is not None:
                remote_mode = remote_mode & 0o7777
            if local_mode != remote_mode:
                self.sftp.chmod(remote_path, local_mode)

        return rattrs

        Upload a file to the remote node.

        :type local_path: ``st``
        :param local_path: File path on the local node.

        :type remote_path: ``str``
        :param remote_path: File path on the remote node.

        :type mode: ``int``
        :param mode: Permissions mode for the file. E.g. 0744.

        :type mirror_local_mode: ``int``
        :param mirror_local_mode: Should remote file mirror local mode.

        :return: Attributes of the remote file.
        :rtype: :class:`posix.stat_result` or ``None``
        
st2common/st2common/runners/paramiko_ssh.py