diff --git a/pscp.c b/pscp.c index b983169f..9827b7f4 100644 --- a/pscp.c +++ b/pscp.c @@ -395,6 +395,17 @@ static void do_cmd(char *host, char *user, char *cmd) } } + /* + * Force protocol to SSH if the user has somehow contrived to + * select one we don't support (e.g. by loading an inappropriate + * saved session). In that situation we assume the port number is + * useless too.) + */ + if (!backend_vt_from_proto(conf_get_int(conf, CONF_protocol))) { + conf_set_int(conf, CONF_protocol, PROT_SSH); + conf_set_int(conf, CONF_port, 22); + } + /* * Disable scary things which shouldn't be enabled for simple * things like SCP and SFTP: agent forwarding, port forwarding, @@ -2242,8 +2253,6 @@ int psftp_main(int argc, char *argv[]) int i; bool sanitise_stderr = true; - settings_set_default_protocol(PROT_SSH); - sk_init(); /* Load Default Settings before doing anything else. */