How to securely deploy PPK file in WPF C# app?

孤者浪人 提交于 2019-12-07 16:58:26

There's generally no way to hide any kind of credentials that (any) application possess from the end user. You can only make them hard to be found, but it's questionable whether it is even worth the effort.

What you can (and should do) is to make sure the credentials grants only as little access as necessary.

So in your case, make sure the account, you authenticate with the private key:

  • has only write access (no read access, nor even list)
  • and has a low disk quota
  • is regularly (or automatically) monitored for any unusual activity

Specifically regarding the private key for WinSCP .NET assembly:

Yes, it has to be stored on the disk (i.e. temporarily extracted to a temp folder). Though you can have the private key encrypted with a passphrase. And have the passphrase hard-coded in the application (obfuscated if your want).

See SessionOptions.SshPrivateKeyPassphrase.


See also WinSCP article on Protecting credentials used for automation.

Since the WinSCP .NET assembly is calling the command-line scripting interface there is probably no way to do this. I'm one of the developers of edtFTPnet/PRO, which is a native .NET implementation of various file-transfer protocols, including SFTP. Our interface allows you to set the private key using a byte-array (see SecureFTPConnection.ClientPrivateKeyBytes). Our product is not free, but it should get you where you want to go.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!