/** * Gets the SSH session using the auth given * * @param \App\Models\Auth $auth Auth model * @param \Ssh\Configuration $configuration SSH configuration object */ protected function getSSHSession($auth, $host) { $session = new SSH2($host); if ($auth->isKeyAuthentication()) { $key = new RSA(); $key->loadKey($auth->credentials->key); if (!$session->login($auth->credentials->username, $key)) { \log::error('Login Failed'); } } else { if (!$session->login($auth->credentials->username, $auth->credentials->password)) { \log::error('Login Failed'); } } return $session; }