<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def open(self, hostname, port=22, username=None, password=None, private_key=None, key_passphrase=None, allow_agent=False, timeout=None):
 """ Open a connection to a remote SSH server In order to connect, either one of these credentials must be supplied: * Password Password-based authentication * Private Key Authenticate using SSH Keys. If the private key is encrypted, it will attempt to load it using the passphrase * Agent Authenticate using the *local* SSH agent. This is the one running alongside wsshd on the server side. """

        try:
            pkey = None
            if private_key:
                pkey = self._load_private_key(private_key, key_passphrase)
            self._ssh.connect(
                hostname=hostname,
                port=port,
                username=username,
                password=password,
                pkey=pkey,
                timeout=timeout,
                allow_agent=allow_agent,
                look_for_keys=False)
        except socket.gaierror as e:
            self._websocket.send(json.dumps({'error':
                'Could not resolve hostname {0}: {1}'.format(
                    hostname, e.args[1])}))
            raise
        except Exception as e:
            self._websocket.send(json.dumps({'error': e.message or str(e)}))
            raise