问题
I'm implementing a Cloud Service (worker role) application in Azure which can add private key files to Pageant from an Azure Local Storage. The p
variable is a Process
which starts cmd.exe
as well.
var filename = "pageant.exe";
var workerRoleStorageName = "PrivateKeys";
var privatekeyfilename = "ThePrivateKey.ppk";
var localResource = RoleEnvironment.GetLocalResource(workerRoleStorageName);
var path = Path.Combine(localResource.RootPath, privatekeyfilename);
p.StandardInput.WriteLine(filename + " "+ path);
I'm in local now, so the content of the path
variable is something like this:
c:\Users\Username\AppData\Local\dftmp\Resources\4691e8f6-fdbd-42ad-af67-986b491aca89\directory\PrivateKeys\ThePrivateKey.ppk
But at the last line of code I have got the following error message:
Couldn't load this key (unable to open file).
It's quite interesting, because if I set up a hard coded simple path it works fine:
var path = @"E:\PrivateKeys\ThePrivateKey.ppk";
I know that the Azure Local Storage folder is hidden in this case, so I tried to set the E:\PrivateKeys
folder to hidden, but it still worked with the hard coded path.
What do you think, why I can't add this file to Pageant from that path?
回答1:
Pageant is unfortunately not very informative when failing to load a private key. It reports "Couldn't load this key (unable to open file)." for any error, including non existence and lack or read permissions.
As is clear from your comments, in this particular instance, it's lack of permissions.
I suppose you need to run your application with higher privileges or with an appropriate role. I would not expect you can run just the cmd.exe
with higher privileges from a less privileged process.
来源:https://stackoverflow.com/questions/25503909/add-private-key-file-to-pageant-from-azure-local-storage-resource