I was trying to connect to WinSCP from my Web Application using C# however I kept on getting an unknown server error. After doing some research (of which I did not find much), my dear friend helped me out figuring out the solution. So here it goes..
winscp> open "firstname.lastname@example.org:22" -privatekey=C:\keys\private.ppk
Searching for host...
Connecting to host...
Continue connecting to an unknown server and add its host key to a cache?
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.
The server's dss key fingerprint is:
ssh-dss 1024 68:57:83:42:c9:42:08:db:13:0d:80:ec:8b:e2:43:c0
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
(Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel
Host key wasn't verified!
Host key fingerprint is ssh-dss 1024 68:57:83:42:c9:42:08:db:13:0d:80:ec:8b:e2:43:c0.
- Open WinSCP in windows.
- Login in to the server you would like to connect from C#.
- Click the Advanced Button
- Go to the “Authentication” Tab
- Browse for the private key, click “Ok”
- Save (optional)
- Once you click “Login”, it will ask you whether you would like to authorize connection/accept the key with server. Agree.
- Now that your server is authenticated, you can go back to your code in C#.
- Open your web.config
- In the <system.web> section add the following:
- <identity impersonate=”true” userName=”my-pc” password=”my-password”/>
- Run code again and the above error should disappear.