anchor.diff:  	    file:rename(B, KnownHosts)
       end.
   
  -setup_dsa(DataDir, UserDir) ->
  -    file:copy(filename:join(DataDir, "id_dsa"), filename:join(UserDir, "id_dsa")),
  -    System = filename:join(UserDir, "system"),
  -    file:make_dir(System),
  -    file:copy(filename:join(DataDir, "ssh_host_dsa_key"), filename:join(System, "ssh_host_dsa_key")),
  -    file:copy(filename:join(DataDir, "ssh_host_dsa_key.pub"), filename:join(System, "ssh_host_dsa_key.pub")),
  -ct:log("DataDir ~p:~n ~p~n~nSystDir ~p:~n ~p~n~nUserDir ~p:~n ~p",[DataDir, file:list_dir(DataDir), System, file:list_dir(System), UserDir, file:list_dir(UserDir)]),
  -    setup_dsa_known_host(DataDir, UserDir),
  -    setup_dsa_auth_keys(DataDir, UserDir).
  -    
  -setup_rsa(DataDir, UserDir) ->
  -    file:copy(filename:join(DataDir, "id_rsa"), filename:join(UserDir, "id_rsa")),
  -    System = filename:join(UserDir, "system"),
  -    file:make_dir(System),
  -    file:copy(filename:join(DataDir, "ssh_host_rsa_key"), filename:join(System, "ssh_host_rsa_key")),
  -    file:copy(filename:join(DataDir, "ssh_host_rsa_key.pub"), filename:join(System, "ssh_host_rsa_key.pub")),
  -ct:log("DataDir ~p:~n ~p~n~nSystDir ~p:~n ~p~n~nUserDir ~p:~n ~p",[DataDir, file:list_dir(DataDir), System, file:list_dir(System), UserDir, file:list_dir(UserDir)]),
  -    setup_rsa_known_host(DataDir, UserDir),
  -    setup_rsa_auth_keys(DataDir, UserDir).
  -
  -setup_ecdsa(Size, DataDir, UserDir) ->
  -    file:copy(filename:join(DataDir, "id_ecdsa"++Size), filename:join(UserDir, "id_ecdsa")),
  -    System = filename:join(UserDir, "system"),
  -    file:make_dir(System),
  -    file:copy(filename:join(DataDir, "ssh_host_ecdsa_key"++Size), filename:join(System, "ssh_host_ecdsa_key")),
  -    file:copy(filename:join(DataDir, "ssh_host_ecdsa_key"++Size++".pub"), filename:join(System, "ssh_host_ecdsa_key.pub")),
  -ct:log("DataDir ~p:~n ~p~n~nSystDir ~p:~n ~p~n~nUserDir ~p:~n ~p",[DataDir, file:list_dir(DataDir), System, file:list_dir(System), UserDir, file:list_dir(UserDir)]),
  -    setup_ecdsa_known_host(Size, System, UserDir),
  -    setup_ecdsa_auth_keys(Size, DataDir, UserDir).
  -
  -setup_eddsa(Alg, DataDir, UserDir) ->
  -    {IdPriv, _IdPub, HostPriv, HostPub} =
  -        case Alg of
  -            ed25519 -> {"id_ed25519", "id_ed25519.pub", "ssh_host_ed25519_key", "ssh_host_ed25519_key.pub"};
  -            ed448   -> {"id_ed448",   "id_ed448.pub",   "ssh_host_ed448_key",   "ssh_host_ed448_key.pub"}
  -        end,
  -    file:copy(filename:join(DataDir, IdPriv), filename:join(UserDir, IdPriv)),
  -    System = filename:join(UserDir, "system"),
  -    file:make_dir(System),
  -    file:copy(filename:join(DataDir, HostPriv), filename:join(System, HostPriv)),
  -    file:copy(filename:join(DataDir, HostPub), filename:join(System, HostPub)),
  -ct:log("DataDir ~p:~n ~p~n~nSystDir ~p:~n ~p~n~nUserDir ~p:~n ~p",[DataDir, file:list_dir(DataDir), System, file:list_dir(System), UserDir, file:list_dir(UserDir)]),
  -    setup_eddsa_known_host(HostPub, DataDir, UserDir),
  -    setup_eddsa_auth_keys(Alg, DataDir, UserDir).
  -
  -clean_dsa(UserDir) ->
  -    del_dirs(filename:join(UserDir, "system")),
  -    file:delete(filename:join(UserDir,"id_dsa")),
  -    file:delete(filename:join(UserDir,"known_hosts")),
  -    file:delete(filename:join(UserDir,"authorized_keys")).
  -
  -clean_rsa(UserDir) ->
  -    del_dirs(filename:join(UserDir, "system")),
  -    file:delete(filename:join(UserDir,"id_rsa")),
  -    file:delete(filename:join(UserDir,"known_hosts")),
  -    file:delete(filename:join(UserDir,"authorized_keys")).
  -
  -setup_dsa_pass_phrase(DataDir, UserDir, Phrase) ->
  -    try
  -        {ok, KeyBin} = file:read_file(filename:join(DataDir, "id_dsa")),
  -        setup_pass_phrase(KeyBin, filename:join(UserDir, "id_dsa"), Phrase),
  -        System = filename:join(UserDir, "system"),
  -        file:make_dir(System),
  -        file:copy(filename:join(DataDir, "ssh_host_dsa_key"), filename:join(System, "ssh_host_dsa_key")),
  -        file:copy(filename:join(DataDir, "ssh_host_dsa_key.pub"), filename:join(System, "ssh_host_dsa_key.pub")),
  -        setup_dsa_known_host(DataDir, UserDir),
  -        setup_dsa_auth_keys(DataDir, UserDir)
  -    of 
  -        _ -> true
  -    catch
  -        _:_ -> false
  -    end.
  -
  -setup_rsa_pass_phrase(DataDir, UserDir, Phrase) ->
  -    try
  -        {ok, KeyBin} = file:read_file(filename:join(DataDir, "id_rsa")),
  -        setup_pass_phrase(KeyBin, filename:join(UserDir, "id_rsa"), Phrase),
  -        System = filename:join(UserDir, "system"),
  -        file:make_dir(System),
  -        file:copy(filename:join(DataDir, "ssh_host_rsa_key"), filename:join(System, "ssh_host_rsa_key")),
  -        file:copy(filename:join(DataDir, "ssh_host_rsa_key.pub"), filename:join(System, "ssh_host_rsa_key.pub")),
  -        setup_rsa_known_host(DataDir, UserDir),
  -        setup_rsa_auth_keys(DataDir, UserDir)
  -    of 
  -        _ -> true
  -    catch
  -        _:_ -> false
  -    end.
  -
  -setup_ecdsa_pass_phrase(Size, DataDir, UserDir, Phrase) ->
  -    try
  -        {ok, KeyBin} = 
  -            case file:read_file(F=filename:join(DataDir, "id_ecdsa"++Size)) of
  -                {error,E} ->
  -                    ct:log("Failed (~p) to read ~p~nFiles: ~p", [E,F,file:list_dir(DataDir)]),
  -                    file:read_file(filename:join(DataDir, "id_ecdsa"));
  -                Other ->
  -                    Other
  -            end,
  -        setup_pass_phrase(KeyBin, filename:join(UserDir, "id_ecdsa"), Phrase),
  -        System = filename:join(UserDir, "system"),
  -        file:make_dir(System),
  -        file:copy(filename:join(DataDir, "ssh_host_ecdsa_key"++Size), filename:join(System, "ssh_host_ecdsa_key")),
  -        file:copy(filename:join(DataDir, "ssh_host_ecdsa_key"++Size++".pub"), filename:join(System, "ssh_host_ecdsa_key.pub")),
  -        setup_ecdsa_known_host(Size, System, UserDir),
  -        setup_ecdsa_auth_keys(Size, DataDir, UserDir)
  -    of 
  -        _ -> true
  -    catch
  -        _:_ -> false
  -    end.
  -
  -setup_pass_phrase(KeyBin, OutFile, Phrase) ->
  -    [{KeyType, _,_} = Entry0] = public_key:pem_decode(KeyBin),
  -    Key =  public_key:pem_entry_decode(Entry0),
  -    Salt = crypto:strong_rand_bytes(8),
  -    Entry = public_key:pem_entry_encode(KeyType, Key,
  -					{{"DES-CBC", Salt}, Phrase}),
  -    Pem = public_key:pem_encode([Entry]),
  -    file:write_file(OutFile, Pem).
  -
  -setup_dsa_known_host(SystemDir, UserDir) ->
  -    {ok, SshBin} = file:read_file(filename:join(SystemDir, "ssh_host_dsa_key.pub")),
  -    [{Key, _}] = public_key:ssh_decode(SshBin, public_key),
  -    setup_known_hosts(Key, UserDir).
  -
  -setup_rsa_known_host(SystemDir, UserDir) ->
  -    {ok, SshBin} = file:read_file(filename:join(SystemDir, "ssh_host_rsa_key.pub")),
  -    [{Key, _}] = public_key:ssh_decode(SshBin, public_key),
  -    setup_known_hosts(Key, UserDir).
  -
  -setup_ecdsa_known_host(_Size, SystemDir, UserDir) ->
  -    {ok, SshBin} = file:read_file(filename:join(SystemDir, "ssh_host_ecdsa_key.pub")),
  -    [{Key, _}] = public_key:ssh_decode(SshBin, public_key),
  -    setup_known_hosts(Key, UserDir).
  -
  -setup_eddsa_known_host(HostPub, SystemDir, UserDir) ->
  -    {ok, SshBin} = file:read_file(filename:join(SystemDir, HostPub)),
  -    [{Key, _}] = public_key:ssh_decode(SshBin, public_key),
  -    setup_known_hosts(Key, UserDir).
  +setup_all_known_hosts(SystemDir, UserDir) ->
  +    PubKeys =
  +        lists:map(fun(Name) ->
  +                          {ok, SshBin} = file:read_file(filename:join(SystemDir, Name)), 
  +                          [{Key, _}] = public_key:ssh_decode(SshBin, public_key),
  +                          Key
  +                  end, filelib:wildcard("*.pub", SystemDir)),
  +    lists:foldl(
  +      fun(Key, Acc) ->
  +              case setup_known_hosts(Key,UserDir) of
  +                  ok -> Acc;
  +                  Other -> Other
  +              end
  +      end, ok, PubKeys).
  +
   
   setup_known_hosts(Key, UserDir) ->
       {ok, Hostname} = inet:gethostname(),
  
positive.code: receive_exec_result([]) ->
      expected;
  receive_exec_result(Msgs) when is_list(Msgs) ->
      ct:log("Expect data! ~p", [Msgs]),
      receive
          Msg ->
              case lists:member(Msg, Msgs) of
                  true ->
                      ct:log("Collected data ~p", [Msg]),
                      receive_exec_result(Msgs--[Msg]);
                  false ->
                      case Msg of
                          {ssh_cm,_,{data,_,1, Data}} ->
                              ct:log("StdErr: ~p~n", [Data]),
                              receive_exec_result(Msgs);
                          Other ->
                              ct:log("Other ~p", [Other]),
                              {unexpected_msg, Other}
                      end
              end
      after 
  	30000 -> ct:fail("timeout ~p:~p",[?MODULE,?LINE])
      end;
  receive_exec_result(Msg) ->
      receive_exec_result([Msg]).
  
negative.code:     end.
  
  receive_exec_end(ConnectionRef, ChannelId) ->
      receive_exec_result(
        [{ssh_cm, ConnectionRef, {eof, ChannelId}},
         {optional, {ssh_cm, ConnectionRef, {exit_status, ChannelId, 0}}},
         {ssh_cm, ConnectionRef, {closed, ChannelId}}
        ]).
  
  receive_exec_result(Data, ConnectionRef, ChannelId) ->
      Eof = {ssh_cm, ConnectionRef, {eof, ChannelId}},
  