Commit 6e402c85 authored by Antenore Gatta's avatar Antenore Gatta

Added ssh_agent support. Closes #395

parent 509713aa
......@@ -48,7 +48,7 @@ struct _RemminaFile
enum
{
SSH_AUTH_PASSWORD, SSH_AUTH_PUBLICKEY, SSH_AUTH_AUTO_PUBLICKEY
SSH_AUTH_PASSWORD, SSH_AUTH_PUBLICKEY, SSH_AUTH_AGENT, SSH_AUTH_AUTO_PUBLICKEY
};
typedef enum
......
......@@ -113,6 +113,7 @@ struct _RemminaFileEditorPriv {
GtkWidget* ssh_server_default_radio;
GtkWidget* ssh_server_custom_radio;
GtkWidget* ssh_server_entry;
GtkWidget* ssh_auth_agent_radio;
GtkWidget* ssh_auth_password_radio;
GtkWidget* ssh_auth_publickey_radio;
GtkWidget* ssh_auth_auto_publickey_radio;
......@@ -284,6 +285,7 @@ static void remmina_file_editor_ssh_enabled_check_on_toggled(GtkToggleButton* to
remmina_file_editor_ssh_server_custom_radio_on_toggled(NULL, gfe);
gtk_widget_set_sensitive(gfe->priv->ssh_charset_combo, enabled);
gtk_widget_set_sensitive(gfe->priv->ssh_username_entry, enabled);
gtk_widget_set_sensitive(gfe->priv->ssh_auth_agent_radio, enabled);
gtk_widget_set_sensitive(gfe->priv->ssh_auth_password_radio, enabled);
gtk_widget_set_sensitive(gfe->priv->ssh_auth_publickey_radio, enabled);
gtk_widget_set_sensitive(gfe->priv->ssh_auth_auto_publickey_radio, enabled);
......@@ -310,7 +312,7 @@ static void remmina_file_editor_create_ssh_privatekey(RemminaFileEditor* gfe, Gt
G_CALLBACK(remmina_file_editor_ssh_auth_publickey_radio_on_toggled), gfe);
priv->ssh_auth_publickey_radio = widget;
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 0, row + 15, 1, 1);
gtk_grid_attach(GTK_GRID(grid), widget, 0, row + 22, 1, 1);
dialog = gtk_file_chooser_dialog_new (_("Identity file"), GTK_WINDOW(gfe), GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
......@@ -324,7 +326,7 @@ static void remmina_file_editor_create_ssh_privatekey(RemminaFileEditor* gfe, Gt
}
g_free(s);
gtk_widget_show(widget);
gtk_grid_attach (GTK_GRID(grid), widget, column + 1, row + 15, 1, 1);
gtk_grid_attach (GTK_GRID(grid), widget, column + 1, row + 22, 1, 1);
priv->ssh_privatekey_chooser = widget;
ssh_privatekey = remmina_file_get_string (priv->remmina_file, "ssh_privatekey");
......@@ -831,23 +833,30 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
}
/* SSH Authentication frame */
remmina_public_create_group (GTK_GRID(grid), _("SSH Authentication"), row + 8, 5, 1);
remmina_public_create_group (GTK_GRID(grid), _("SSH Authentication"), row + 8, 6, 1);
row++;
priv->ssh_username_entry = remmina_file_editor_create_text (gfe, grid, row + 10, 0,
_("User name"), NULL);
row++;
widget = gtk_radio_button_new_with_label (NULL, _("Password"));
widget = gtk_radio_button_new_with_label (NULL, _("SSH Agent (automatic)"));
gtk_widget_show(widget);
gtk_grid_attach (GTK_GRID(grid), widget, 0, row + 19, 1, 1);
priv->ssh_auth_agent_radio = widget;
row++;
widget = gtk_radio_button_new_with_label_from_widget (
GTK_RADIO_BUTTON(priv->ssh_auth_agent_radio), _("Password"));
gtk_widget_show(widget);
gtk_grid_attach (GTK_GRID(grid), widget, 0, row + 21, 1, 1);
priv->ssh_auth_password_radio = widget;
row++;
widget = gtk_radio_button_new_with_label_from_widget (
GTK_RADIO_BUTTON(priv->ssh_auth_password_radio), _("Public key (automatic)"));
gtk_widget_show(widget);
gtk_grid_attach (GTK_GRID(grid), widget, 0, row + 20, 1, 1);
gtk_grid_attach (GTK_GRID(grid), widget, 0, row + 22, 1, 1);
priv->ssh_auth_auto_publickey_radio = widget;
row++;
......@@ -882,6 +891,8 @@ static void remmina_file_editor_create_ssh_tab(RemminaFileEditor* gfe, RemminaPr
priv->ssh_auth_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AUTO_PUBLICKEY ?
priv->ssh_auth_auto_publickey_radio :
remmina_file_get_int (priv->remmina_file, "ssh_auth", 0) == SSH_AUTH_AGENT ?
priv->ssh_auth_agent_radio :
priv->ssh_auth_password_radio), TRUE);
remmina_file_editor_ssh_enabled_check_on_toggled (NULL, gfe);
......@@ -936,6 +947,7 @@ static void remmina_file_editor_protocol_combo_on_changed(GtkComboBox* combo, Re
priv->ssh_server_custom_radio = NULL;
priv->ssh_server_entry = NULL;
priv->ssh_username_entry = NULL;
priv->ssh_auth_agent_radio = NULL;
priv->ssh_auth_password_radio = NULL;
priv->ssh_auth_publickey_radio = NULL;
priv->ssh_auth_auto_publickey_radio = NULL;
......@@ -998,7 +1010,11 @@ static void remmina_file_editor_update_ssh(RemminaFileEditor* gfe)
priv->ssh_auth_auto_publickey_radio
&& gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(priv->ssh_auth_auto_publickey_radio)) ?
SSH_AUTH_AUTO_PUBLICKEY : SSH_AUTH_PASSWORD));
SSH_AUTH_AUTO_PUBLICKEY :
priv->ssh_auth_agent_radio
&& gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(priv->ssh_auth_agent_radio)) ?
SSH_AUTH_AGENT: SSH_AUTH_PASSWORD));
remmina_file_set_string(
priv->remmina_file,
"ssh_privatekey",
......
......@@ -223,6 +223,22 @@ remmina_ssh_auth_auto_pubkey (RemminaSSH* ssh)
return 1;
}
static gint
remmina_ssh_auth_agent (RemminaSSH* ssh)
{
TRACE_CALL("remmina_ssh_auth_agent");
gint ret;
ret = ssh_userauth_agent (ssh->session, NULL);
if (ret != SSH_AUTH_SUCCESS) {
remmina_ssh_set_error (ssh, _("SSH public key authentication with ssh agent failed: %s"));
return 0;
}
ssh->authenticated = TRUE;
return 1;
}
gint
remmina_ssh_auth (RemminaSSH *ssh, const gchar *password)
{
......@@ -247,6 +263,9 @@ remmina_ssh_auth (RemminaSSH *ssh, const gchar *password)
case SSH_AUTH_PUBLICKEY:
return remmina_ssh_auth_pubkey (ssh);
case SSH_AUTH_AGENT:
return remmina_ssh_auth_agent (ssh);
case SSH_AUTH_AUTO_PUBLICKEY:
return remmina_ssh_auth_auto_pubkey (ssh);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment