I am using WinSCP .NET assembly to upload files over SFTP, and one of the SessionOptions
properties is SshPrivateKeyPath
which is the location of the private key file that I created with PuTTYgen. The file is on the C:
drive on my PC:
SessionOptions sessionOptions = new SessionOptions
{
SshPrivateKeyPath = "C:\Users\blah\Documents\MyPrivateKey.ppk";
}
note: I actually have the filepath as a config setting, but you get the idea.
Doing this makes sense to me as when deployed to a test/live environment, the key and its location will be different. Also as it's not part of the project it keeps it out of source control.
However I can't seem to find a standard approach to this and I worry that what I'm doing is not the right thing to do. Any suggestions?