I am trying to connect to a SFTP server for a client of ours and send files in an automated process using MS Windows. The details I have received from the client do not include the password. I instead have the public-private key pair using PuTTY.

The typical connection string used is as follows

open sftp://username:password.SFTPURL:port -hostkey="ssh-dss 1024 XXXXXXX"

I do not however understand how to specify the private key in this connection, instead of the password. How do I tell the script where the private key lies and is there a particular key word to use when connecting using public key?

I am new at this so please bear with me.


    Is the SFTP client tool given, or can you use one of your choice? Because if you have the liberty to choose, then I would recommend trying out Syncplify.me FTP Script!, which allows you to write scripts like this, using passwordless public-key authentication:

    varCli: TSFTPClient;beginCli :=TSFTPClient.Create;tryCli.ServerAddr :='your.remote.host';Cli.Username :='username';Cli.AddPK('c:\user_key.rsa');if Cli.Open thenbegin// Add your code here.http:// ... Cli.Close;end;finallyCli.Free;end;end.

      Your Answer


      By posting your answer, you agree to the privacy policy and terms of service.

      Not the answer you're looking for? Browse other questions tagged or ask your own question.