Script to automate WinSCP file download with certificate authentication

Advertisement

gautam.gupta1@...
Guest

Script to automate WinSCP file download with certificate authentication

I am working on a script which will automate the downloading of files from remote sftp server.
The issue is certificate authentication
Right now I am using WinSCP GUI and in the Advanced settings of the WinSCP session with remote server I have supplied the SSL certificate.
WinSCP connects to remote server using this certificate and once sessions is established I go to a remote directory and copy a file to local directory.
I need to automate this and schedule it so that in every 30 minutes the script is run and if a new file is copied to remote server directory, it will be copied to the local directory.
I have one script which works fine for FTP but for SFTP with certificate I need help in creating a script which can be used to connect to remote SFTP server passing on certificate authentication and download the file.

Thanks
Gautam

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: script to automate winscp file download with certificate authentication

SFTP does not use client certificates.
So either you mean private key (used with SFTP/SSH).
Or you mean FTPS (which uses TLS/SSL and hence the certificates).

For private key, use the -privatekey switch.
For client certificate, use the -clientcert switch.
https://winscp.net/eng/docs/scriptcommand_open

In any case, you have have the GUI generate the script for you:
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

gautam.gupta1@...
Guest

script to automate winscp file download with certificate authentication

thanks Martin

I am able to connect to FTPS using -privatekey and command link interface
open sftp://test1:test123;fingerprint=ssh-rsa-xxxxxxxxxxxxxx -privatekey=<Filepath> -passphrase=XXXXX
Next step is to download any new file in the remote directory (filename_xxxx.csv) to local directory....and write to a log file and send a status mail alert to specific email id.
can you help with this ?

Thanks

Reply with quote

Advertisement

You can post new topics in this forum