WinSCP dll SshPrivateKeyPath

Advertisement

Markb
Joined:
Posts:
1
Location:
England

WinSCP dll SshPrivateKeyPath

Hi,
I'm trying to configure my application to use Host client PPK authentication so;
1. The host checks that it can find a matching host public key (fingerprint) on the client and
2. The client has generated a Private/Public key pair and placed it's public key onto the host.
I've supplied the path of the private client ppk file to the SshPrivateKeyPath attribute.
Here's my code;
lvoSessionOptions           = NEW WinSCP.SessionOptions().

lvoTransferOptions          = NEW WinSCP.TransferOptions().
lvoRemoteFileInfoCollection = NEW WinSCP.RemoteFileInfoCollection().
lvoTransferOptions:TransferMode = TransferMode:BINARY.

ASSIGN
  lvoSessionOptions:HostName              = SFTP_Host
  lvoSessionOptions:UserName              = lvcUsername
  lvoSessionOptions:Protocol              = Protocol:Sftp
  lvoSessionOptions:PortNumber            = SFTP_Port.
  
  /* If password is provided, uses standard user/pwd auth else uses PPK */
  IF lvcPassword NE "" THEN
    lvoSessionOptions:Password = lvcPassword.
  
  /* The path to the clients local private pk file (ppk) - from which the public key is sent to the host */
  IF SFTP_ClientPrivateKeyFile NE "" THEN
    lvoSessionOptions:SshPrivateKeyPath = SFTP_ClientPrivateKeyFile.      
  
  /* the host SFTP server's "fingerprint" */
  lvoSessionOptions:SshHostKeyFingerprint = SFTP_HostPublicKey.
  
  /* If the client's local Private/Public key pair is encrypted we'll need this */
  IF SFTP_ClientPrivateKeyPassword NE "" THEN
    lvoSessionOptions:PrivateKeyPassphrase  = SFTP_ClientPrivateKeyPassword.
  
SFTPClient = NEW WinSCP.Session().
SFTPClient:Open(lvoSessionOptions).   
The issue seems to be that no notice is paid by the SFTP server of the Clients private key location, it can be anything or blank, but the client still connects via the Hosts public key fingerprint matching that of the clients.
I'm using the Bitvise SFTP server.
Have I made a mistake in the code or in the configuration of the server?
Does WinSCP perform both client and host public key comparisons?
Thanks,
Mark.

Screenshot 2021-05-06 140334.png

Reply with quote

Advertisement

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

Re: WinSCP dll SshPrivateKeyPath

The host key is not used for authentication.
See https://winscp.net/eng/docs/ssh_keys

Don't you have your key loaded to Pageant?

If you want us to investigate further, please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Advertisement

You can post new topics in this forum