with closing(connect(user, host, port)) as ssh:
    with closing(ssh.open_sftp()) as sftp:
        with closing(sftp.open('remote_filename')) as file:
            for line in file:
                pass
Read a file from server with ssh using python