ssh fetcher: No longer allow deprecated and insecure DSA algorithm

This commit is contained in:
Hylke Bons 2016-06-09 18:56:07 -07:00 committed by Hylke Bons
parent b45b4c8165
commit 7f5b5e5b5b
2 changed files with 11 additions and 18 deletions

View file

@ -39,10 +39,10 @@ namespace Sparkles {
StartInfo.FileName = path; StartInfo.FileName = path;
StartInfo.Arguments = args; StartInfo.Arguments = args;
StartInfo.CreateNoWindow = true; StartInfo.CreateNoWindow = true;
StartInfo.RedirectStandardOutput = true; StartInfo.RedirectStandardOutput = true;
StartInfo.RedirectStandardError = true; StartInfo.RedirectStandardError = true;
StartInfo.UseShellExecute = false; StartInfo.UseShellExecute = false;
EnableRaisingEvents = true; EnableRaisingEvents = true;
} }

View file

@ -89,27 +89,20 @@ namespace Sparkles {
string FetchHostKey () string FetchHostKey ()
{ {
Logger.LogInfo ("Auth", "Fetching host key for " + RemoteUrl.Host); Logger.LogInfo ("Auth", string.Format ("Fetching host key for {0}", RemoteUrl.Host));
string [] key_types = {"rsa", "dsa", "ecdsa"}; var ssh_keyscan = new Command ("ssh-keyscan", string.Format ("-t rsa -p 22 {0}", RemoteUrl.Host));
foreach (string key_type in key_types) {
string args = "-t " + key_type + " " + "-p" + " ";
if (RemoteUrl.Port < 1) if (RemoteUrl.Port > 0)
args += "22 " + RemoteUrl.Host; ssh_keyscan.StartInfo.Arguments = string.Format ("-t rsa -p {0} {1}", RemoteUrl.Port, RemoteUrl.Host);
else
args += RemoteUrl.Port + " " + RemoteUrl.Host;
var ssh_keyscan = new Command ("ssh-keyscan", args); string host_key = ssh_keyscan.StartAndReadStandardOutput ();
string host_key = ssh_keyscan.StartAndReadStandardOutput ();
if (ssh_keyscan.ExitCode == 0 && !string.IsNullOrWhiteSpace (host_key))
return host_key;
if (ssh_keyscan.ExitCode == 0 && !string.IsNullOrWhiteSpace (host_key))
return host_key;
}
return null; return null;
} }
string DeriveFingerprint (string public_key) string DeriveFingerprint (string public_key)
{ {