.PPK file and upload automation in C#

Advertisement

brettrsmithjr
Joined:
Posts:
4

.PPK file and upload automation in C#

I was able to run and activate the WinSCP.com file, but how do you script with C# how to include a username, a private PPK file to open the sftp gateway and then upload a file from a network directory? I would greatly appreciate your help. Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,252
Location:
Prague, Czechia

Re: .PPK file and upload automation in C#

For a general guide see
https://winscp.net/eng/docs/guide_automation

brettrsmithjr wrote:

how do you script with C# how to include a username, a private PPK file to open the sftp gateway
https://winscp.net/eng/docs/scriptcommand_open
https://winscp.net/eng/docs/session_url

and then upload a file from a network directory?
https://winscp.net/eng/docs/scriptcommand_put
_________________
Martin Prikryl

Reply with quote

brettrsmithjr
Joined:
Posts:
4

OK, so how am I supposed to do it if I do not have a password, just a username and a ftp site with port information? I also want to know how can I write this in C#?

Reply with quote

TimU
Joined:
Posts:
25
Location:
Sydney

brettrsmithjr wrote:

OK, so how am I supposed to do it if I do not have a password, just a username and a ftp site with port information?
1) Have you been given the private key by the S/FTP site administrator, or have you generated one yourself?
2) Were you given the key in PPK or OpenSSH format?

Assuming (please check & confirm) that you've been supplied with the Private Key, and that it's in PPK format, you can use this command to establish your connection with the S/FTP site:
open <protocol>://<username>@<hostname> -privatekey="<FullPathToKeyFile>.ppk" -hostkey="<your servers host key>"

example:
open sftp://SFTPUser@SFTPServer.domain.local -privatekey="D:\sftp\keys\SFTPUser.ppk" -hostkey="ssh-rsa 1024 e2:dd:11:2e:82:32:ab:62:59:1c:c8:62:1d:2b:28:99"


brettrsmithjr wrote:

I also want to know how can I write this in C#?
See here for C# programming help.

Reply with quote

Advertisement

You can post new topics in this forum