Take port into account when retrieving SSH host keys

This commit is contained in:
= 2012-09-05 14:37:31 +02:00
parent 625c953660
commit 63ab6918ec

View file

@ -261,6 +261,7 @@ namespace SparkleLib {
private string GetHostKey ()
{
string host = RemoteUrl.Host;
int port = RemoteUrl.Port;
SparkleLogger.LogInfo ("Auth", "Fetching host key for " + host);
Process process = new Process () {
@ -268,7 +269,7 @@ namespace SparkleLib {
};
process.StartInfo.FileName = "ssh-keyscan";
process.StartInfo.Arguments = "-t rsa " + host;
process.StartInfo.Arguments = "-t rsa -p " + port.ToString() + " " + host;
process.StartInfo.WorkingDirectory = SparkleConfig.DefaultConfig.TmpPath;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
@ -281,7 +282,7 @@ namespace SparkleLib {
string host_key = process.StandardOutput.ReadToEnd ().Trim ();
process.WaitForExit ();
if (process.ExitCode == 0)
if (process.ExitCode == 0 && host_key != null)
return host_key;
else
return null;