Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
645 views
in Technique[技术] by (71.8m points)

.net - Exception when connecting to SFTP server using WinSCP C# code - PrivateKeyPassphrase is set, but not SshPrivateKeyPath and TlsClientCertificatePath

I am building an application which uses C# code to connect to an SFP server. The other party says that they do not provide key files. When connecting to their SFTP server via FileZilla only using host + user + passphrase + port, I successfully connect (after accepting the host key that appears on the pop up window).

However when running the code I keep getting the below exception:

SessionOptions.PrivateKeyPassphrase is set, but neither SessionOptions.SshPrivateKeyPath nor SessionOptions.TlsClientCertificatePath is set.

I am using WinSCP.SessionOptions to build the connection.

How can establish a connection without having to point to a .ppk file as FileZilla does?

Many thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are not connecting with the user and passphrase, but with a password.

So you need to set SessionOptions.Password property, not SessionOptions.PrivateKeyPassphrase.


The passphrase is indeed used in combination with private keys only.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...