diff --git a/configure.ac b/configure.ac
index ac889ad3a403999443647d14e3b47a8523b4c472..86de2fea67782f472d57080245c0cbfc6e6ad906 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1495,6 +1495,11 @@ if test X"$OPT_LIBSSH2" != Xno; then
        export LD_LIBRARY_PATH
        AC_MSG_NOTICE([Added $LIB_LIBSSH2 to LD_LIBRARY_PATH])
     fi
+  else
+    dnl no libssh2, revert back to clean variables
+    LDFLAGS=$CLEANLDFLAGS
+    CPPFLAGS=$CLEANCPPFLAGS
+    LIBS=$CLEANLIBS
   fi
 fi