@@ -235,6 +235,25 @@ init_per_testcase(mlkem768x25519_hybrid_secret_encoding, Config) ->
235235 false -> {skip , " X25519 or ML-KEM768 not supported" };
236236 true -> Config
237237 end ;
238+ init_per_testcase (sshd_simple_exec , Config ) ->
239+ case proplists :get_value (tag_alg , Config ) of
240+ {public_key , Algs } ->
241+ KeyInfo = user_key_files_for (Algs ),
242+ case has_user_key_for (Algs ) of
243+ true ->
244+ ? CT_LOG (" sshd_simple_exec: identity key check passed~n "
245+ " Algs: ~p~n "
246+ " Key files found: ~p " , [Algs , KeyInfo ]),
247+ Config ;
248+ false ->
249+ ? CT_LOG (" sshd_simple_exec: no identity key~n "
250+ " Algs: ~p~n "
251+ " Key files checked: ~p " , [Algs , KeyInfo ]),
252+ {skip , {no_user_identity_key , Algs }}
253+ end ;
254+ _ ->
255+ Config
256+ end ;
238257init_per_testcase (_TC , Config ) ->
239258 Config .
240259
@@ -504,6 +523,46 @@ supports(Tag, Alg, Algos) ->
504523 split (Tag , Alg )).
505524
506525
526+ % %%----------------------------------------------------------------
527+ % %% Check that the user has a local identity key matching the algorithm.
528+ % %% Used by init_per_testcase(sshd_simple_exec, ...) to skip early
529+ % %% instead of waiting 37s+ for auth failure against the OS sshd.
530+
531+ has_user_key_for (Algs ) when is_list (Algs ) ->
532+ lists :all (fun has_user_key_for_single /1 , Algs );
533+ has_user_key_for (Alg ) ->
534+ has_user_key_for_single (Alg ).
535+
536+ user_key_files_for (Algs ) when is_list (Algs ) ->
537+ lists :flatmap (fun user_key_files_for /1 , Algs );
538+ user_key_files_for (Alg ) ->
539+ Home = os :getenv (" HOME" ),
540+ KeyFiles = key_filenames (Alg ),
541+ [{Alg , F , filelib :is_regular (filename :join ([Home , " .ssh" , F ]))}
542+ || F <- KeyFiles ].
543+
544+ has_user_key_for_single (Alg ) ->
545+ case ssh_file :user_key (Alg , []) of
546+ {ok , _Key } -> true ;
547+ _ -> false
548+ end .
549+
550+ key_filenames (Alg ) ->
551+ case Alg of
552+ 'ssh-rsa' -> [" id_rsa" ];
553+ 'rsa-sha2-256' -> [" id_rsa" ];
554+ 'rsa-sha2-512' -> [" id_rsa" ];
555+ 'ssh-dss' -> [" id_dsa" ];
556+ 'ssh-ed25519' -> [" id_ed25519" ];
557+ 'ssh-ed448' -> [" id_ed448" ];
558+ 'ecdsa-sha2-nistp256' -> [" id_ecdsa" , " id_ecdsa_sk" ];
559+ 'ecdsa-sha2-nistp384' -> [" id_ecdsa" ];
560+ 'ecdsa-sha2-nistp521' -> [" id_ecdsa" ];
561+ _ -> []
562+ end .
563+
564+ % %%----------------------------------------------------------------
565+
507566extract_algos (Spec ) ->
508567 [{Tag ,get_atoms (List )} || {Tag ,List } <- Spec ].
509568
0 commit comments