setup: Start thread to create first run key pair. Fixes #694
This commit is contained in:
parent
bf45b91ddc
commit
5fe7284385
|
@ -814,48 +814,40 @@ namespace SparkleShare {
|
||||||
string key_file_path = Path.Combine (keys_path, key_file_name);
|
string key_file_path = Path.Combine (keys_path, key_file_name);
|
||||||
|
|
||||||
if (File.Exists (key_file_path)) {
|
if (File.Exists (key_file_path)) {
|
||||||
SparkleHelpers.DebugInfo ("Auth", "Key already exists ('" + key_file_name + "'), " +
|
SparkleHelpers.DebugInfo ("Auth", "Keypair exists ('" + key_file_name + "'), leaving it untouched");
|
||||||
"leaving it untouched");
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!Directory.Exists (keys_path))
|
||||||
|
Directory.CreateDirectory (keys_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists (keys_path))
|
Process process = new Process () {
|
||||||
Directory.CreateDirectory (keys_path);
|
EnableRaisingEvents = true
|
||||||
|
};
|
||||||
|
|
||||||
if (!File.Exists (key_file_name)) {
|
process.StartInfo.WorkingDirectory = keys_path;
|
||||||
Process process = new Process () {
|
process.StartInfo.UseShellExecute = false;
|
||||||
EnableRaisingEvents = true
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
};
|
process.StartInfo.FileName = "ssh-keygen";
|
||||||
|
process.StartInfo.CreateNoWindow = true;
|
||||||
process.StartInfo.WorkingDirectory = keys_path;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.FileName = "ssh-keygen";
|
|
||||||
process.StartInfo.CreateNoWindow = true;
|
|
||||||
|
|
||||||
process.StartInfo.Arguments = "-t rsa " + // crypto type
|
process.StartInfo.Arguments = "-t rsa " + // crypto type
|
||||||
"-P \"\" " + // password (none)
|
"-P \"\" " + // password (none)
|
||||||
"-C \"" + System.Net.Dns.GetHostName () + "\" " + // key comment
|
"-C \"" + System.Net.Dns.GetHostName () + "\" " + // key comment
|
||||||
"-f " + key_file_name; // file name
|
"-f " + key_file_name; // file name
|
||||||
|
|
||||||
process.Start ();
|
process.Start ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Auth", "Created private key '" + key_file_name + "'");
|
if (process.ExitCode == 0)
|
||||||
SparkleHelpers.DebugInfo ("Auth", "Created public key '" + key_file_name + ".pub'");
|
SparkleHelpers.DebugInfo ("Auth", "Created keypair '" + key_file_name + "'");
|
||||||
|
else
|
||||||
|
SparkleHelpers.DebugInfo ("Auth", "Could not create keypair '" + key_file_name + "'");
|
||||||
|
|
||||||
// Add some restrictions to what the key can
|
// Create an easily accessible copy of the public
|
||||||
// do when uploaded to the server
|
// key in the user's SparkleShare folder
|
||||||
// string public_key = File.ReadAllText (key_file_path + ".pub");
|
File.Copy (key_file_path + ".pub", Path.Combine (SparklePath, UserName + "'s key.txt"), true);
|
||||||
// public_key = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty " + public_key;
|
|
||||||
// File.WriteAllText (key_file_path + ".pub", public_key);
|
|
||||||
|
|
||||||
// Create an easily accessible copy of the public
|
|
||||||
// key in the user's SparkleShare folder
|
|
||||||
File.Copy (key_file_path + ".pub",
|
|
||||||
Path.Combine (SparklePath, UserName + "'s key.txt"),
|
|
||||||
true); // Overwriting is allowed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace SparkleShare {
|
||||||
Program.Controller.GenerateKeyPair ();
|
Program.Controller.GenerateKeyPair ();
|
||||||
Program.Controller.ImportPrivateKey ();
|
Program.Controller.ImportPrivateKey ();
|
||||||
})
|
})
|
||||||
);
|
).Start ();
|
||||||
|
|
||||||
TutorialPageNumber = 1;
|
TutorialPageNumber = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue