def exists_remote(host, path):
    """Test if a file exists at path on a host accessible with SSH."""
status = subprocess.call(['ssh', host, 'test -f {}'.format(pipes.quote(path))])
if status == 0:
    return True
if status == 1:
    pass
Checking a file existence on a remote SSH server using Python