Topic "sftp passwordless connection"

Author Message
B-Lec
[View user's profile]

Joined: 2014-10-01
Posts: 2
Hello,

Does anyone knows if there is a way to open an sftp connexion without password using the .NET Assembly ?

I've tried the following piece of code without success :

SessionOptions sessionOptions = new SessionOptions();

sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = "HOST";
sessionOptions.UserName = "USER";
sessionOptions.SshPrivateKeyPath = @"C:\PATH\privatekey.ppk";
sessionOptions.PortNumber = 22;
sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 aa:7b:5d:59:16:47:9b:ec:14:ab:ee:8d:1d:cd:7f:cf";

using (Session session = new Session())
{

session.ExecutablePath = @"C:\PATH\WinSCP.exe";
session.SessionLogPath = "Log.txt";
session.Open(sessionOptions);
}

The assembly keeps throwing 'host key wasn't verified'

Log content :

. 2014-10-01 17:24:09.610 --------------------------------------------------------------------------
. 2014-10-01 17:24:09.611 Looking up host "HOST"
. 2014-10-01 17:24:09.611 Connecting to HOST port 22
. 2014-10-01 17:24:09.674 Server version: SSH-2.0-OpenSSH_5.8
. 2014-10-01 17:24:09.674 Using SSH protocol version 2
. 2014-10-01 17:24:09.674 We claim version: SSH-2.0-WinSCP_release_5.5.5
. 2014-10-01 17:24:09.694 Doing Diffie-Hellman group exchange
. 2014-10-01 17:24:09.774 Doing Diffie-Hellman key exchange with hash SHA-256
. 2014-10-01 17:24:10.819 Verifying host key rsa2 0x10001,0xba12ac6f46bd16b4 70299ffaeee4f665 015774ae4d32f0b6 a3dff757f3608d64 8d113a9d98caf9e3 dc53e1d52ca7a51b a2469927d5889171 b99c90e1c685a22e bbea101f532b2f63 efdce65a3a1c7c91 6deb96c9d3dd6575 0d133a6cb9649b15 94f09b8bfeecda69 e2762245c8eced35 b0167fb335d1833a 5dd4e9678a93a2c6 7e9d0fb9f77aa221 f0b33adb8b45a210 e1ad762bec06594a 0c1c3029798b0ee6 8ebf33e425554e5b e150ce9a2f6765ff 7b2f51b974ea69dd 15be8db96ee19abb 9393cc2127dbf178 9fb6341ae3f1cfb1 0ca5905137f20f76 3ff9b0c8cf25c076 c9f622373618847f 9c38ea0380a6fdfc d862e795ae98a062 fdc5fd827f28d82b with fingerprint ssh-rsa 2048 3c:83:28:b8:43:6e:a6:b3:90:c2:0a:a2:4e:19:50:90
. 2014-10-01 17:24:10.822 Host key does not match configured key ssh-rsa 2048 aa:7b:5d:59:16:47:9b:ec:14:ab:ee:8d:1d:cd:7f:cf
. 2014-10-01 17:24:10.822 Asking user:
. 2014-10-01 17:24:10.822 **Continue connecting to an unknown server and add its host key to a cache?**
. 2014-10-01 17:24:10.822
. 2014-10-01 17:24:10.822 The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
. 2014-10-01 17:24:10.822
. 2014-10-01 17:24:10.823 The server's rsa2 key fingerprint is:
. 2014-10-01 17:24:10.823 ssh-rsa 2048 3c:83:28:b8:43:6e:a6:b3:90:c2:0a:a2:4e:19:50:90
. 2014-10-01 17:24:10.823
. 2014-10-01 17:24:10.823 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. ()
. 2014-10-01 17:24:10.823 Attempt to close connection due to fatal exception:
* 2014-10-01 17:24:10.823 Host key fingerprint is ssh-rsa 2048 3c:83:28:b8:43:6e:a6:b3:90:c2:0a:a2:4e:19:50:90.
* 2014-10-01 17:24:10.823 (Exception) **Host key wasn't verified!**
. 2014-10-01 17:24:10.823 Closing connection.
. 2014-10-01 17:24:10.823 Sending special code: 12
B-Lec
[View user's profile]

Joined: 2014-10-01
Posts: 2
Don't bother anymore, I've used SharpSSH instead, works fine, and easier to use
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
The value you have set to sessionOptions.SshHostKeyFingerprint (ssh-rsa 2048 aa:7b:5d:59:16:47:9b:ec:14:ab:ee:8d:1d:cd:7f:cf) does not match with the actual host key (ssh-rsa 2048 3c:83:28:b8:43:6e:a6:b3:90:c2:0a:a2:4e:19:50:90).
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License