1

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.

Thanks!

0

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:

var
  Cli: TSFTPClient;
begin
  Cli := TSFTPClient.Create;
  try
    Cli.ServerAddr := 'your.remote.host';
    Cli.Username := 'username';
    Cli.AddPK('c:\user_key.rsa');
    if Cli.Open then
    begin
      // Add your code here...
      // ...      
      Cli.Close;
    end;
  finally
    Cli.Free;
  end;
end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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