public function connect($host, $auth, $port = 22, $timeout = 10)
	{
		$this->ssh = new SSH2($host, $port, $timeout);

		if (!isset($auth['key']) && isset($auth['username'])) {
			// Login via username/password

			$username = $auth['username'];
			$password = isset($auth['password']) ? $auth['password'] : '';

			if (!$this->ssh->login($username, $password))
				throw new LoginFailedException(Yii::t(
					'Yii2SshConsole',
					'Login failed for user {username} using password {answer}!',
					[
						'username' => $username,
						'answer' => !empty($password) ? 1 : 0
					]
				));
			else
				return true;
		} elseif (isset($auth['key']) and isset($auth['username'])) {
			// Login via private key

			$username = $auth['username'];
			$password = isset($auth['key_password']) ? $auth['key_password'] : '';

			$key = new RSA;
			if (!empty($password)) {
				$key->setPassword($password);
			}
			$key->loadKey(file_get_contents($auth['key']));

			if (!$this->ssh->login($username, $key))
				throw new LoginFailedException(Yii::t(
					'Yii2SshConsole',
					'Login failed for user {username} using key with password {answer}!',
					[
						'username' => $username,
						'answer' => !empty($password) ? 1 : 0
					]
				));
			else
				return true;
		} else {
			// No username given

			throw new LoginUnknownException(Yii::t(
					'Yii2SshConsole',
					'No username given!'
			));
		}

		return false;
	}