Those are some good reads, I appreciate the info. StackOverflow (SOF) is pretty good too, they usually have a decent response rate to questions. I tried using the different methods listed, but all came short for the same reason. I'm assuming because they still are not set to return a 'file (path)' format, but are set to return the content of a file instead. According to the documentation, the source of SSH.NET, the 'open' method requires a local file.
So what is happening is the file is never downloaded to the client in a file format, merely strings. Using the last example, WebClient, I can 'GET' the file, and store it as a string, but I have no method to conver the string to a 'path_to_a_file'....or do I? =)
Here is an example for the last one I tried from the SOF, WebClient:
Let me know of any thoughts that come to mind, I think I'm close. I'm wondering also if there is a way to reference a String in memory as a 'file'
So what is happening is the file is never downloaded to the client in a file format, merely strings. Using the last example, WebClient, I can 'GET' the file, and store it as a string, but I have no method to conver the string to a 'path_to_a_file'....or do I? =)
Here is an example for the last one I tried from the SOF, WebClient:
private void button1_Click(object sender, EventArgs e)
{
try
{
//CREDENTIALS
var webClient = new WebClient();
string myKey = webClient.DownloadString("https://10.1.1.45/pk.php?pk=joes_pk");
string hostname = "10.1.1.10";
int port = 22;
string username = "unix_username";
//Objects INIT
PrivateKeyFile privatekey = new PrivateKeyFile(myKey);
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 connection:" + exc.Message.ToString() + ":" + exc.StackTrace.ToString());
}
}
So it throws this expected error:
System.ArgumentException was caught
Message=Illegal characters in path.
Source=mscorlib
StackTrace:
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.Open(String path, FileMode mode)
at Renci.SshNet.PrivateKeyFile..ctor(String fileName)
at RCERTPCDC.RencieTest.button1_Click(Object sender, EventArgs e) in C:\Users\~\Documents\Visual Studio 2010\Projects\Test\RencieTest.cs:line 40
InnerException:
Line 40 is:PrivateKeyFile privatekey = new PrivateKeyFile(myKey);
PrivateKeyFile class requires a fileName (path), not a string which has the contents of the file. So when I am trying to instantiate the privateKey object as a PrivateKeyFile, by passing in a string, it obviously cannot. Let me know of any thoughts that come to mind, I think I'm close. I'm wondering also if there is a way to reference a String in memory as a 'file'