Repository: dbeaver/dbeaver
Issue: SSH connection defaults to OS login, if server login not saved in settings

### Description

It's related to credential popup changes from #18017 - now if SSH is set to use encrypted certificates there will be a popup asking for certificate password, but there's no way to enter server login. If the login is stored in settings - it will work - but in case the login is left empty, the connection will default to OS login.

### DBeaver Version

Community Edition 23.1.2

### Operating System

Windows 10

### Database and driver

_No response_

### Steps to reproduce

1. Configure SSH with jump server (probably without the jump server will be the same)
2. Use encrypted certificate as auth, leave passphrases blank
3. Leave the "user name" blank
4. Try to connect
The connection will ask for passphrase, but not for login and then it will default to using OS user name as SSH server login.

### Additional context

_No response_

Changed files:
plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
plugins/org.jkiss.dbeaver.net.ssh.ui/src/org/jkiss/dbeaver/ui/net/ssh/SSHTunnelConfiguratorUI.java

diff --git a/plugins/org.jkiss.dbeaver.net.ssh.ui/src/org/jkiss/dbeaver/ui/net/ssh/SSHTunnelConfiguratorUI.java b/plugins/org.jkiss.dbeaver.net.ssh.ui/src/org/jkiss/dbeaver/ui/net/ssh/SSHTunnelConfiguratorUI.java
index ffd49fbb4f..7f59eee123 100644
--- a/plugins/org.jkiss.dbeaver.net.ssh.ui/src/org/jkiss/dbeaver/ui/net/ssh/SSHTunnelConfiguratorUI.java
+++ b/plugins/org.jkiss.dbeaver.net.ssh.ui/src/org/jkiss/dbeaver/ui/net/ssh/SSHTunnelConfiguratorUI.java
@@ -256,7 +256,7 @@ public class SSHTunnelConfiguratorUI implements IObjectPropertyConfigurator<Obje
                     ? SSHUIMessages.model_ssh_dialog_credentials_passphrase
                     : SSHUIMessages.model_ssh_dialog_credentials_password,
                 password,
-                type.equals(SSHConstants.AuthType.PUBLIC_KEY),
+                false,
                 false
             );
         } catch (Exception e) {
@@ -298,9 +298,7 @@ public class SSHTunnelConfiguratorUI implements IObjectPropertyConfigurator<Obje
                         DBPAuthInfo dbpAuthInfo = promptCredentialsDialog(authType, configuration.getUserName(),
                             configuration.getPassword());
                         if (dbpAuthInfo != null) {
-                            if (authType.equals(SSHConstants.AuthType.PASSWORD)) {
-                                configuration.setUserName(dbpAuthInfo.getUserName());
-                            }
+                            configuration.setUserName(dbpAuthInfo.getUserName());
                             configuration.setPassword(dbpAuthInfo.getUserPassword());
                         }
                         checkJumpServerConfiguration(tunnel);
@@ -337,19 +335,18 @@ public class SSHTunnelConfiguratorUI implements IObjectPropertyConfigurator<Obje
                     );
                     if (tunnel.getRequiredCredentials(configuration, getJumpServerSettingsPrefix())
                         != DBWTunnel.AuthCredentials.NONE) {
-                        DBPAuthInfo dbpAuthInfo = promptCredentialsDialog(authType,
-                            configuration.getStringProperty(getJumpServerSettingsPrefix()
-                                                            + DBConstants.PROP_ID_NAME),
-                            configuration.getSecureProperty(getJumpServerSettingsPrefix()
-                                                            + DBConstants.PROP_FEATURE_PASSWORD)
+                        DBPAuthInfo dbpAuthInfo = promptCredentialsDialog(
+                            authType,
+                            configuration.getStringProperty(getJumpServerSettingsPrefix() + DBConstants.PROP_ID_NAME),
+                            configuration.getSecureProperty(
+                                getJumpServerSettingsPrefix() + DBConstants.PROP_FEATURE_PASSWORD)
                         );
                         if (dbpAuthInfo != null) {
-                            if (authType.equals(SSHConstants.AuthType.PASSWORD)) {
-                                configuration.setProperty(getJumpServerSettingsPrefix() + DBConstants.PROP_ID_NAME,
-                                    dbpAuthInfo.getUserName()
-                                );
-                            }
-                            configuration.setSecureProperty(getJumpServerSettingsPrefix() + DBConstants.PROP_FEATURE_PASSWORD,
+                            configuration.setProperty(getJumpServerSettingsPrefix() + DBConstants.PROP_ID_NAME,
+                                dbpAuthInfo.getUserName()
+                            );
+                            configuration.setSecureProperty(
+                                getJumpServerSettingsPrefix() + DBConstants.PROP_FEATURE_PASSWORD,
                                 dbpAuthInfo.getUserPassword()
                             );
                         }
diff --git a/plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java b/plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
index 2aec12602b..0194debc58 100644
--- a/plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
+++ b/plugins/org.jkiss.dbeaver.registry/src/org/jkiss/dbeaver/registry/DataSourceDescriptor.java
@@ -1928,9 +1928,7 @@ public class DataSourceDescriptor
         }
 
         if (networkHandler != null) {
-            if (authType == DBWTunnel.AuthCredentials.CREDENTIALS) {
-                networkHandler.setUserName(authInfo.getUserName());
-            }
+            networkHandler.setUserName(authInfo.getUserName());
             networkHandler.setPassword(authInfo.getUserPassword());
             networkHandler.setSavePassword(authInfo.isSavePassword());
             actualConfig.updateHandler(networkHandler);
@@ -1989,7 +1987,7 @@ public class DataSourceDescriptor
             authType == DBWTunnel.AuthCredentials.PASSWORD
                 ? RegistryMessages.dialog_connection_auth_passphrase
                 : RegistryMessages.dialog_connection_auth_password, password,
-            authType != DBWTunnel.AuthCredentials.CREDENTIALS,
+            false,
             canSavePassword
         );
         return authInfo;