diff options
author | Fredrik Gustafsson <[email protected]> | 2012-11-01 10:59:16 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2012-11-02 11:34:34 +0100 |
commit | 1defe44d6dbbb01bf5591c0491474e86cff105b2 (patch) | |
tree | cf6b41a7076536a285f97d90c37ce3ed3d49fec9 /lib/ssh/src/ssh_connection_handler.erl | |
parent | d5733bc3e34449affde2594d85b905c8ab440d42 (diff) | |
download | otp-1defe44d6dbbb01bf5591c0491474e86cff105b2.tar.gz otp-1defe44d6dbbb01bf5591c0491474e86cff105b2.tar.bz2 otp-1defe44d6dbbb01bf5591c0491474e86cff105b2.zip |
Option to ssh:connect {pref_public_key_algs, list()} where you can give the algorithms you want to use
Diffstat (limited to 'lib/ssh/src/ssh_connection_handler.erl')
-rw-r--r-- | lib/ssh/src/ssh_connection_handler.erl | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 5b3d1b8a1b..d8950a7b67 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -718,8 +718,18 @@ init_ssh(server = Role, Vsn, Version, Options, Socket) -> available_host_keys = supported_host_keys(Role, KeyCb, Options) }. -supported_host_keys(client, _, _) -> - ["ssh-rsa", "ssh-dss"]; +supported_host_keys(client, _, Options) -> + try + case extract_algs(proplists:get_value(pref_public_key_algs, Options, false), []) of + false -> + ["ssh-rsa", "ssh-dss"]; + Algs -> + Algs + end + catch + exit:Reason -> + {stop, {shutdown, Reason}} + end; supported_host_keys(server, KeyCb, Options) -> lists:foldl(fun(Type, Acc) -> case available_host_key(KeyCb, Type, Options) of @@ -731,7 +741,19 @@ supported_host_keys(server, KeyCb, Options) -> end, [], %% Prefered alg last so no need to reverse ["ssh-dss", "ssh-rsa"]). - +extract_algs(false, _) -> + false; +extract_algs([],[]) -> + false; +extract_algs([], NewList) -> + lists:reverse(NewList); +extract_algs([H|T], NewList) -> + case H of + ssh_dsa -> + extract_algs(T, ["ssh-dss"|NewList]); + ssh_rsa -> + extract_algs(T, ["ssh-rsa"|NewList]) + end. available_host_key(KeyCb, "ssh-dss"= Alg, Opts) -> case KeyCb:host_key('ssh-dss', Opts) of {ok, _} -> |