aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_file.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2012-02-16 09:24:30 +0100
committerIngela Anderton Andin <[email protected]>2012-02-16 09:24:30 +0100
commit4d9dd06871d268942df763e556a0afb0bb6cf471 (patch)
tree020df21faf1409067cf8c92327ade0b7e1f856be /lib/ssh/src/ssh_file.erl
parent4a9cf8de2125832cdc636693ec23f625f195b9e8 (diff)
parent489fac442f15f08adf7745fb2d399cd521f0db74 (diff)
downloadotp-4d9dd06871d268942df763e556a0afb0bb6cf471.tar.gz
otp-4d9dd06871d268942df763e556a0afb0bb6cf471.tar.bz2
otp-4d9dd06871d268942df763e556a0afb0bb6cf471.zip
Merge branch 'ia/ssh/pass-phrase-protected-keys/OTP-6400' into maint
* ia/ssh/pass-phrase-protected-keys/OTP-6400: Remove unused files from test data as it is confusing Add support for key files protected by pass phrases
Diffstat (limited to 'lib/ssh/src/ssh_file.erl')
-rw-r--r--lib/ssh/src/ssh_file.erl28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index 8569051bee..d05fa8e09a 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -46,7 +46,10 @@
%% Used by server
host_key(Algorithm, Opts) ->
File = file_name(system, file_base_name(Algorithm), Opts),
- Password = proplists:get_value(password, Opts, ignore),
+ %% We do not expect host keys to have pass phrases
+ %% so probably we could hardcod Password = ignore, but
+ %% we keep it as an undocumented option for now.
+ Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
decode(File, Password).
@@ -68,9 +71,9 @@ is_host_key(Key, PeerName, Algorithm, Opts) ->
false
end.
-user_key(Alg, Opts) ->
- File = file_name(user, identity_key_filename(Alg), Opts),
- Password = proplists:get_value(password, Opts, ignore),
+user_key(Algorithm, Opts) ->
+ File = file_name(user, identity_key_filename(Algorithm), Opts),
+ Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore),
decode(File, Password).
@@ -210,10 +213,20 @@ do_lookup_host_key(Host, Alg, Opts) ->
Error -> Error
end.
-identity_key_filename("ssh-dss") -> "id_dsa";
-identity_key_filename("ssh-rsa") -> "id_rsa".
+identity_key_filename("ssh-dss") ->
+ "id_dsa";
+identity_key_filename("ssh-rsa") ->
+ "id_rsa".
+
+identity_pass_phrase("ssh-dss") ->
+ dsa_pass_phrase;
+identity_pass_phrase('ssh-dss') ->
+ dsa_pass_phrase;
+identity_pass_phrase('ssh-rsa') ->
+ rsa_pass_phrase;
+identity_pass_phrase("ssh-rsa") ->
+ rsa_pass_phrase.
-
lookup_host_key_fd(Fd, Host, KeyType) ->
case io:get_line(Fd, '') of
eof ->
@@ -290,7 +303,6 @@ is_auth_key(Key, Key) ->
is_auth_key(_,_) ->
false.
-
default_user_dir()->
{ok,[[Home|_]]} = init:get_argument(home),
UserDir = filename:join(Home, ".ssh"),