auth info: Clean up
This commit is contained in:
parent
8e7b05f3dd
commit
c0bda40378
|
@ -26,24 +26,21 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public static SSHAuthenticationInfo DefaultAuthenticationInfo;
|
public static SSHAuthenticationInfo DefaultAuthenticationInfo;
|
||||||
|
|
||||||
|
public string PrivateKeyFilePath { get; private set; }
|
||||||
|
public string PrivateKey { get; private set; }
|
||||||
|
|
||||||
public string PrivateKeyFilePath;
|
public string PublicKeyFilePath { get; private set; }
|
||||||
public string PrivateKey;
|
public string PublicKey { get; private set; }
|
||||||
|
|
||||||
public string PublicKeyFilePath;
|
public string KnownHostsFilePath { get; private set; }
|
||||||
public string PublicKey;
|
|
||||||
|
|
||||||
public string KnownHostsFilePath;
|
|
||||||
|
|
||||||
|
|
||||||
string Path;
|
readonly string Path;
|
||||||
|
|
||||||
|
|
||||||
public SSHAuthenticationInfo ()
|
public SSHAuthenticationInfo ()
|
||||||
{
|
{
|
||||||
string config_path = IO.Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath);
|
Path = IO.Path.Combine (IO.Path.GetDirectoryName (SparkleConfig.DefaultConfig.FullPath), "ssh");
|
||||||
Path = IO.Path.Combine (config_path, "ssh");
|
|
||||||
|
|
||||||
KnownHostsFilePath = IO.Path.Combine (Path, "known_hosts");
|
KnownHostsFilePath = IO.Path.Combine (Path, "known_hosts");
|
||||||
|
|
||||||
if (IO.Directory.Exists (Path)) {
|
if (IO.Directory.Exists (Path)) {
|
||||||
|
@ -84,7 +81,6 @@ namespace SparkleLib {
|
||||||
bool CreateKeyPair ()
|
bool CreateKeyPair ()
|
||||||
{
|
{
|
||||||
string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm") + ".key";
|
string key_file_name = DateTime.Now.ToString ("yyyy-MM-dd_HH\\hmm") + ".key";
|
||||||
string key_file_path = IO.Path.Combine (Path, key_file_name);
|
|
||||||
string computer_name = Dns.GetHostName ();
|
string computer_name = Dns.GetHostName ();
|
||||||
|
|
||||||
if (computer_name.EndsWith (".local"))
|
if (computer_name.EndsWith (".local"))
|
||||||
|
@ -102,24 +98,18 @@ namespace SparkleLib {
|
||||||
|
|
||||||
var process = new SparkleProcess ("ssh-keygen", arguments);
|
var process = new SparkleProcess ("ssh-keygen", arguments);
|
||||||
process.StartInfo.WorkingDirectory = Path;
|
process.StartInfo.WorkingDirectory = Path;
|
||||||
|
|
||||||
process.Start ();
|
process.Start ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
|
|
||||||
if (process.ExitCode == 0) {
|
if (process.ExitCode == 0) {
|
||||||
PrivateKeyFilePath = key_file_path;
|
|
||||||
PrivateKey = IO.File.ReadAllText (key_file_path);
|
|
||||||
|
|
||||||
PublicKeyFilePath = key_file_path + ".pub";
|
|
||||||
PublicKey = IO.File.ReadAllText (key_file_path + ".pub");
|
|
||||||
|
|
||||||
SparkleLogger.LogInfo ("Auth", "Created key pair: " + key_file_name);
|
SparkleLogger.LogInfo ("Auth", "Created key pair: " + key_file_name);
|
||||||
return true;
|
ImportKeys ();
|
||||||
|
|
||||||
} else {
|
return true;
|
||||||
SparkleLogger.LogInfo ("Auth", "Could not create key pair");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SparkleLogger.LogInfo ("Auth", "Could not create key pair");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue