<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def establish_ssh_connection(ip, ssh_private_key_file, ssh_user, port, attempts=5, timeout=None):
 """ Establish ssh connection and return paramiko client. Raises: IpaSSHException: If connection cannot be established in given number of attempts. """

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    while attempts:
        try:
            client.connect(
                ip,
                port=port,
                username=ssh_user,
                key_filename=ssh_private_key_file,
                timeout=timeout
            )
        except:  # noqa: E722
            attempts -= 1
            time.sleep(10)
        else:
            return client

    raise IpaSSHException(
        'Failed to establish SSH connection to instance.'
    )