Hey all,
Situation:
Is this the right method for what I'm trying to do? Something like: (psuedo)
SK
Situation:
- Want to connect from C# app to UNIX server using RSA PrivateKey (stored on local c: drive)with no passphrase. (works)
-
Now I'd like to store the PrivateKey on another UNIX machine and be able to Stream / Read it in to be used by the same C# app. The reason is that i have the C# app installed on several machines, and I'd like to have them all be able to access the PrivateKey. This is especially true, since I will be changing my key every 90 days roughly. This will eliminate the need of distributing the PrivateKey too all the Windows machines everytime it changes. Can I pass in a 'path' to a URL or should I read the file using a System.Windows.Forms.WebBrowser?
Is this the right method for what I'm trying to do? Something like: (psuedo)
private void button1_Click(object sender, EventArgs e)
{
try
{
//CREDENTIALS
//Works
//string path = "C:\\Users\\Joe\\Documents\\DAR\\Keys\\joes_pk";
//new path to web server with PK
string path = "https://10.1.1.45/pk.php?pk=joes_pk";
string unix_hostname = "10.1.1.10";
int port = 22;
string username = "unix_username";
//Objects INIT
PrivateKeyFile privatekey = new PrivateKeyFile(path);
SshClient client = new SshClient(hostname, port, username, privatekey);
client.Connect();
//RUN command
if (client.IsConnected)
{
string cmd = "ls -la";
MessageBox.Show("Conected! Running " + cmd);
var output = client.RunCommand(cmd);
MessageBox.Show(output.Result.ToString() + " Will disconnect now...");
client.Disconnect();
}
}
catch (Exception exc)
{
MessageBox.Show("Error on makeConnection:" + exc.Message.ToString() + ":" + exc.StackTrace.ToString());
}
}
Let me know what ideas yall have on the best way to make a centralized PrivateKey that I can use with SSH.NET, thanks!SK