diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
index cf4d8171c02..151bd25c370 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
@@ -518,10 +518,6 @@ public class JSchConnection implements IRemoteConnection {
return fAttributes;
}
- public String getKeyFile() {
- return fAttributes.getAttribute(JSchConnectionAttributes.KEYFILE_ATTR, EMPTY_STRING);
- }
-
public JSchConnectionManager getManager() {
return fManager;
}
@@ -835,13 +831,13 @@ public class JSchConnection implements IRemoteConnection {
private Session newSession(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
SubMonitor progress = SubMonitor.convert(monitor, 10);
try {
- if (!isPasswordAuth()) {
- fJSchService.getJSch().addIdentity(getKeyFile());
- }
Session session = fJSchService.createSession(getAddress(), getPort(), getUsername());
session.setUserInfo(new JSchUserInfo(authenticator));
if (isPasswordAuth()) {
+ session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
session.setPassword(getPassword());
+ } else {
+ session.setConfig("PreferredAuthentications", "publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (getProxyCommand().equals(EMPTY_STRING) && getProxyConnectionName().equals(EMPTY_STRING)) {
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10)); // connect without proxy
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java
index 0829ee21797..6e3250f4be8 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java
@@ -36,7 +36,6 @@ public class JSchConnectionAttributes {
public static final String PROXYCOMMAND_ATTR = "JSCH_PROXYCOMMAND_ATTR"; //$NON-NLS-1$
public static final String IS_PASSWORD_ATTR = "JSCH_IS_PASSWORD_ATTR"; //$NON-NLS-1$
public static final String PASSPHRASE_ATTR = "JSCH_PASSPHRASE_ATTR"; //$NON-NLS-1$
- public static final String KEYFILE_ATTR = "JSCH_KEYFILE_ATTR"; //$NON-NLS-1$
public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_ATTR"; //$NON-NLS-1$
public static final String USE_LOGIN_SHELL_ATTR = "JSCH_USE_LOGIN_SHELL_ATTR"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java
index 9c868670253..1fef9769203 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java
@@ -53,11 +53,6 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
return Collections.unmodifiableMap(fWorkingAttributes.getAttributes());
}
- @Override
- public String getKeyFile() {
- return fWorkingAttributes.getAttribute(JSchConnectionAttributes.KEYFILE_ATTR, EMPTY_STRING);
- }
-
/*
* (non-Javadoc)
*
@@ -227,11 +222,6 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
fWorkingAttributes.setAttribute(JSchConnectionAttributes.IS_PASSWORD_ATTR, Boolean.toString(flag));
}
- public void setKeyFile(String keyFile) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.KEYFILE_ATTR, keyFile);
- }
-
/*
* (non-Javadoc)
*
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/Messages.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/Messages.java
index d14e5e2aec4..1667f5b6c6f 100755
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/Messages.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/Messages.java
@@ -27,6 +27,7 @@ public class Messages extends NLS {
public static String JSchConnectionPage_Please_enter_name_for_connection;
public static String JSchConnectionPage_Proxy;
public static String JSchConnectionPage_Help;
+ public static String JSchConnectionPage_KeysAtSSH2;
public static String JSchConnectionPage_SelectCommand;
public static String JSchConnectionPage_SelectConnection;
public static String JSchConnectionPage_Settings0;
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/messages.properties b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/messages.properties
index 5b2404c1d3d..250aa5e5ddc 100755
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/messages.properties
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/messages/messages.properties
@@ -14,6 +14,7 @@ JSchConnectionPage_Edit_properties_of_an_existing_connection=Edit properties of
JSchConnectionPage_Please_enter_name_for_connection=Please enter a name for the connection
JSchConnectionPage_Proxy=SSH Proxy Settings
JSchConnectionPage_Help=If 'Local' is selected and proxy command is empty, no proxy is used.\nSee Network Connections for SOCKS and HTTP proxy options.
+JSchConnectionPage_KeysAtSSH2=Keys are set at Network Connections, SSH2
JSchConnectionPage_SelectCommand=Enter a local or remote command such as 'nc %h %p'. Can be empty for an ssh gateway.
JSchConnectionPage_SelectConnection=Select 'Remote' for an ssh gateway or a remote proxy command.
JSchConnectionPage_Settings0=Connection Settings
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
index e000efe0d95..d68e61ed029 100755
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
@@ -11,7 +11,6 @@
*/
package org.eclipse.remote.internal.jsch.ui.wizards;
-import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -28,7 +27,6 @@ import org.eclipse.remote.internal.jsch.core.JSchConnectionAttributes;
import org.eclipse.remote.internal.jsch.core.JSchConnectionWorkingCopy;
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
-import org.eclipse.remote.ui.widgets.RemoteFileWidget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -70,7 +68,6 @@ public class JSchConnectionPage extends WizardPage {
private Text fPassphraseText;
private Text fPortText;
private Text fTimeoutText;
- private RemoteFileWidget fFileWidget;
private String fInitialName = "Remote Host"; //$NON-NLS-1$
private Set fInvalidConnectionNames;
@@ -133,7 +130,6 @@ public class JSchConnectionPage extends WizardPage {
Label portLabel = new Label(settingsComp, SWT.NONE);
portLabel.setText(Messages.JSchNewConnectionPage_Port);
- portLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fPortText = new Text(settingsComp, SWT.BORDER | SWT.SINGLE);
fPortText.setText(Integer.toString(JSchConnection.DEFAULT_PORT));
fPortText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
@@ -141,7 +137,6 @@ public class JSchConnectionPage extends WizardPage {
Label timeoutLabel = new Label(settingsComp, SWT.NONE);
timeoutLabel.setText(Messages.JSchNewConnectionPage_Timeout);
- timeoutLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fTimeoutText = new Text(settingsComp, SWT.BORDER | SWT.SINGLE);
fTimeoutText.setText(Integer.toString(JSchConnection.DEFAULT_TIMEOUT));
fTimeoutText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
@@ -158,39 +153,18 @@ public class JSchConnectionPage extends WizardPage {
private void createAuthControls(Composite parent) {
Composite controls = new Composite(parent, SWT.NONE);
- controls.setLayout(new GridLayout(2, false));
+ controls.setLayout(new GridLayout(3, false));
controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label hostLabel = new Label(controls, SWT.NONE);
hostLabel.setText(Messages.JSchNewConnectionPage_Host);
- hostLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fHostText = new Text(controls, SWT.BORDER | SWT.SINGLE);
- fHostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ fHostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label userLabel = new Label(controls, SWT.NONE);
userLabel.setText(Messages.JSchNewConnectionPage_User);
- userLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fUserText = new Text(controls, SWT.BORDER | SWT.SINGLE);
- fUserText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
- // User option box
- fPasswordButton = new Button(controls, SWT.RADIO);
- fPasswordButton.setText(Messages.JSchNewConnectionPage_Password_based_authentication);
- fPasswordButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
- fPasswordButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- validateFields();
- updateEnablement();
- }
- });
-
- // Password field
- Label passwordLabel = new Label(controls, SWT.NONE);
- passwordLabel.setText(Messages.JSchNewConnectionPage_Password);
- passwordLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- fPasswordText = new Text(controls, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
- fPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ fUserText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
// Key option box
fPublicKeyButton = new Button(controls, SWT.RADIO);
@@ -204,24 +178,53 @@ public class JSchConnectionPage extends WizardPage {
}
});
- // Key file selection
- fFileWidget = new RemoteFileWidget(controls, SWT.NONE, 0, null, ""); //$NON-NLS-1$
- fFileWidget.setConnection(RemoteServices.getLocalServices().getConnectionManager()
- .getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME));
- fFileWidget.setLabel(Messages.JSchNewConnectionPage_File_with_private_key);
- fFileWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ Link link = new Link(controls, SWT.WRAP);
+ final GridData linkLayoutData = new GridData(GridData.FILL_HORIZONTAL);
+ link.setLayoutData(linkLayoutData);
+ final String PREFS_PAGE_ID_NET_SSH = "org.eclipse.jsch.ui.SSHPreferences"; //$NON-NLS-1$
+ link.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(getShell(), PREFS_PAGE_ID_NET_SSH,
+ new String[] { PREFS_PAGE_ID_NET_SSH }, null);
+ dlg.open();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // ignore
+ }
+ });
+ link.setText(Messages.JSchConnectionPage_KeysAtSSH2);
// Passphrase field
Label passphraseLabel = new Label(controls, SWT.NONE);
passphraseLabel.setText(Messages.JSchNewConnectionPage_Passphrase);
- passphraseLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fPassphraseText = new Text(controls, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
- fPassphraseText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ fPassphraseText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
- fPasswordButton.setSelection(true);
- fPublicKeyButton.setSelection(false);
- controls.setTabList(new Control[] { fHostText, fUserText, fPasswordButton, fPasswordText, fPublicKeyButton, fFileWidget,
- fPassphraseText });
+ // User option box
+ fPasswordButton = new Button(controls, SWT.RADIO);
+ fPasswordButton.setText(Messages.JSchNewConnectionPage_Password_based_authentication);
+ fPasswordButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
+ fPasswordButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ validateFields();
+ updateEnablement();
+ }
+ });
+
+ // Password field
+ Label passwordLabel = new Label(controls, SWT.NONE);
+ passwordLabel.setText(Messages.JSchNewConnectionPage_Password);
+ fPasswordText = new Text(controls, SWT.BORDER | SWT.SINGLE | SWT.PASSWORD);
+ fPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+
+ fPasswordButton.setSelection(false);
+ fPublicKeyButton.setSelection(true);
+ controls.setTabList(new Control[] { fHostText, fUserText, fPublicKeyButton,
+ fPassphraseText, fPasswordButton, fPasswordText });
}
@Override
@@ -243,7 +246,6 @@ public class JSchConnectionPage extends WizardPage {
Label label = new Label(topControl, SWT.NONE);
label.setText(Messages.JSchNewConnectionPage_Connection_name);
- label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fConnectionName = new Text(topControl, SWT.BORDER | SWT.SINGLE);
fConnectionName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
@@ -345,7 +347,6 @@ public class JSchConnectionPage extends WizardPage {
fPasswordText.setText(fConnection.getPassword());
} else {
fPassphraseText.setText(fConnection.getPassphrase());
- fFileWidget.setLocationPath(fConnection.getKeyFile());
}
fProxyCommandText.setText(fConnection.getProxyCommand());
@@ -380,10 +381,6 @@ public class JSchConnectionPage extends WizardPage {
if (passphrase != null) {
fPassphraseText.setText(passphrase);
}
- String file = fInitialAttributes.get(JSchConnectionAttributes.KEYFILE_ATTR);
- if (file != null) {
- fFileWidget.setLocationPath(file);
- }
fProxyConnectionWidget.setConnection(RemoteServices.getLocalServices().getConnectionManager().getConnection(
IRemoteConnectionManager.LOCAL_CONNECTION_NAME));
}
@@ -393,7 +390,6 @@ public class JSchConnectionPage extends WizardPage {
fConnectionName.addModifyListener(fDataModifyListener);
fHostText.addModifyListener(fDataModifyListener);
fUserText.addModifyListener(fDataModifyListener);
- fFileWidget.addModifyListener(fDataModifyListener);
fPasswordText.addModifyListener(fDataModifyListener);
fPassphraseText.addModifyListener(fDataModifyListener);
fPortText.addModifyListener(fDataModifyListener);
@@ -481,9 +477,6 @@ public class JSchConnectionPage extends WizardPage {
if (!fConnection.getPassphrase().equals(fPassphraseText.getText().trim())) {
fConnection.setPassphrase(fPassphraseText.getText().trim());
}
- if (!fConnection.getKeyFile().equals(fFileWidget.getLocationPath())) {
- fConnection.setKeyFile(fFileWidget.getLocationPath());
- }
if (fConnection.isPasswordAuth() != fPasswordButton.getSelection()) {
fConnection.setIsPasswordAuth(fPasswordButton.getSelection());
}
@@ -513,7 +506,6 @@ public class JSchConnectionPage extends WizardPage {
boolean isPasswordAuth = fPasswordButton.getSelection();
fPasswordText.setEnabled(isPasswordAuth);
fPassphraseText.setEnabled(!isPasswordAuth);
- fFileWidget.setEnabled(!isPasswordAuth);
}
private String validateAdvanced() {
@@ -544,9 +536,6 @@ public class JSchConnectionPage extends WizardPage {
} else if (fUserText.getText().trim().length() == 0) {
message = Messages.JSchNewConnectionPage_User_name_cannot_be_empty;
}
- if (message == null) {
- message = validatePasskey();
- }
if (message == null && fProxyConnectionWidget.getConnection() == null) {
message = Messages.JSchConnectionPage_selectProxyConnection;
}
@@ -558,22 +547,4 @@ public class JSchConnectionPage extends WizardPage {
setPageComplete(message == null);
}
- private String validatePasskey() {
- if (!fPasswordButton.getSelection()) {
- if (fFileWidget.getLocationPath().trim().length() == 0) {
- return Messages.JSchNewConnectionPage_Private_key_path_cannot_be_empty;
- }
- File path = new File(fFileWidget.getLocationPath().trim());
- if (!path.exists()) {
- return Messages.JSchNewConnectionPage_Private_key_file_does_not_exist;
- }
- if (!path.isFile()) {
- return Messages.JSchNewConnectionPage_Private_key_file_is_invalid;
- }
- if (!path.canRead()) {
- return Messages.JSchNewConnectionPage_Private_key_file_cannot_be_read;
- }
- }
- return null;
- }
}