session BUGFIX nc_connect_libssh fixed

FD option cannot be checked, parameters
now assigned to session properly.
diff --git a/src/session.h b/src/session.h
index c6f7f9b..5f695cf 100644
--- a/src/session.h
+++ b/src/session.h
@@ -230,8 +230,8 @@
  *
  * SSH session can have any options set, they will not be modified. If no options were set,
  * host 'localhost', port 22, and the username detected from the EUID is used. If socket is
- * set and connected only username must be set/is detected. Or the \p ssh_session can already
- * be authenticated in which case it is used directly.
+ * set and connected only the host and the username must be set/is detected. Or the \p ssh_session
+ * can already be authenticated in which case it is used directly.
  *
  * Function is provided only via nc_client.h header file and only when libnetconf2 is compiled with libssh support.
  *
diff --git a/src/session_ssh.c b/src/session_ssh.c
index 22ae67a..69e6951 100644
--- a/src/session_ssh.c
+++ b/src/session_ssh.c
@@ -42,6 +42,7 @@
 #   include <validator/validator-compat.h>
 #endif
 
+#include <libssh/libssh.h>
 #include <libyang/libyang.h>
 
 #include "libnetconf.h"
@@ -989,22 +990,18 @@
     session->ti_type = NC_TI_LIBSSH;
     session->ti.libssh.session = ssh_session;
 
-    if (ssh_get_fd(ssh_session) == -1) {
+    /* was port set? */
+    ssh_options_get_port(ssh_session, (unsigned int *)&port);
+
+    if (ssh_options_get(ssh_session, SSH_OPTIONS_HOST, &host) != SSH_OK) {
         /*
-         * There is no file descriptor, we need to create it. (TCP/IP layer)
+         * There is no file descriptor (detected based on the host, there is no way to check
+         * the SSH_OPTIONS_FD directly :/), we need to create it. (TCP/IP layer)
          */
 
-        /* was host, port set? */
-        if (ssh_options_get(ssh_session, SSH_OPTIONS_HOST, &host) != SSH_OK) {
-            host = NULL;
-        }
-        ssh_options_get_port(ssh_session, (unsigned int *)&port);
-
         /* remember host */
-        if (!host) {
-            host = strdup("localhost");
-            ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_HOST, host);
-        }
+        host = strdup("localhost");
+        ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_HOST, host);
 
         /* create and connect socket */
         sock = nc_connect_getsocket(host, port);
@@ -1014,16 +1011,14 @@
         ssh_options_set(session->ti.libssh.session, SSH_OPTIONS_FD, &sock);
     }
 
+    /* was username set? */
+    ssh_options_get(ssh_session, SSH_OPTIONS_USER, &username);
+
     if (!ssh_is_connected(ssh_session)) {
         /*
          * We are connected, but not SSH authenticated. (Transport layer)
          */
 
-        /* was username set? */
-        if (ssh_options_get(ssh_session, SSH_OPTIONS_USER, &username) != SSH_OK) {
-            username = NULL;
-        }
-
         /* remember username */
         if (!username) {
             pw = getpwuid(getuid());