Error: WinSCP. NET Assembly

Advertisement

ctapia
Joined:
Posts:
1

Error: WinSCP. NET Assembly

Good morning,
I need a help, I am trying to download some files from an SFTP connection, as I read there is "WinSCP. NET Assembly winscp.dll" to program in C #. NET, I found only one in the FAR, but when I try to add it as reference to my C # project. NET displays an error

---------------------------
Microsoft Visual Studio
---------------------------
A reference to 'D:\CTAPIA\Plantillas\NET\LeerSFTP\WindowsFormsApplication1\WindowsFormsApplication1\WinSCP\WinSCP.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

I want to do the following, Example:

https://winscp.net/eng/docs/library_session_getfiles#example

thanks,

Advertisement

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

Re: Error: WinSCP. NET Assembly

WinSCP.dll in FAR package in plugin to FAR file manager.

WinSCP .NET assembly was not release yet. It will be included in 5.0.6 beta, coming out in few weeks.

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Thank you

Martin,

First I would like to thank you for the WinSCP software and the abundant documentation, it has simplified my development when doing sFTP transfers.

Second - If there is any way I could convince you [read: beg....please ;) ] to release a stub or class we could code against now it would be much appreciated. I would even be open to being a guinea pig (a.k.a. Beta User) until the WinSCP.dll stablizes. This would provide the opportunity for some of us to know the methods, properties, etc. and we can fill it in with our own code for now but just replace with your .dll when the day arrives.

All the best,

j0se

martin
Site Admin
martin avatar

Re: Thank you

I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Re: Thank you

Martin, email sent about a minute ago.

All the best,

Joe

Advertisement

MsMaria
Guest

Re: Thank you

Can I too request for a copy of the .NET library please? Email msmaria0503 at gmail com. Thank you!

joelrb
Joined:
Posts:
1
Location:
Philippines

Re: Thank you

martin wrote:

I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?

Hi Martin,

I've been using WinSCP in .Net as described here: https://winscp.net/eng/docs/guide_dotnet.

I also want to try the .Net Assembly (DLL). Can you send me a preview so I can test also? I'll give feedback on my use of it. Please send to joelrb at gmail.com

Many thanks!

Joel

martin
Site Admin
martin avatar

Re: Error: WinSCP. NET Assembly

I have sent an email to all of you. Looking forward for your feedback.

flavio66
Joined:
Posts:
1
Location:
Carrara - Italy

Hi Martin,
great job!
I'm writing a internal tool and i need to transfer files over ssh.
I'm using "SFTP file transfers in .NET" as a base but if i could have a preview of the DLL it would be a great improvement: could you send me to lodoli at comune.carrara.ms.it ?.
I'll return all feedback from my work.

Thanks a lot

Flavio

Advertisement

rjl
Joined:
Posts:
1
Location:
Copenhagen, Denmark

Can I have a try at this beta aswell?

martin
Site Admin
martin avatar

Re: Error: WinSCP. NET Assembly

I have emailed you too.

ronwello
Joined:
Posts:
2
Location:
United States

.NET Assembly

Could I have a go with the preview of this assembly as well? I'm very interested in it. Thanks. Good work on winscp, by the way.

andys
Joined:
Posts:
3

.NET Assembly Code

Hello, would it also be possible for me to get the DLL for testing purposes
Thanks

Advertisement

martin
Site Admin
martin avatar

Re: .NET Assembly

I'm in a middle of rewrite of the assembly. Will contact you once that's done.

ronwello
Joined:
Posts:
2
Location:
United States

Re: .NET Assembly

martin wrote:

I'm in a middle of rewrite of the assembly. Will contact you once that's done.

Thanks! I'm very much looking forward to it.

Jaryth
Guest

Re: .NET Assembly

martin wrote:

I'm in a middle of rewrite of the assembly. Will contact you once that's done.

When your ready I would also be happy to help beta test the assembly it will streamline the entire process.

Many thanks

johnmichael.quinlan@googlemail.com

bebbe
Joined:
Posts:
1
Location:
Germany, Bavaria

Re: .NET Assembly

Hi!

Could you send me the beta of the assembly as well?

Many thanks
bebbe

Advertisement

martin
Site Admin
martin avatar

Re: .NET Assembly

I have sent a new version of the assembly to all of you.

lambo77
Joined:
Posts:
1
Location:
dublin Ireland

Re: .NET Assembly

martin wrote:

I have sent a new version of the assembly to all of you.


would I be able to get a Copy of the dll too?

Guest

Re: Thank you

martin wrote:

I can send it to you for preview, once the interface is stable enough. Should be in few days. Can you email me as a reminder?

Hi Martin,
can you send me the assembly as well?
My email is elwood.net [at] gmail.com
Thanks in advance.
Best Regards,
Elwood.

pi_guy
Joined:
Posts:
1

Hi would it be possible to get a preview of the assembly? I'm doing dev for a file transfer heavy application and am try to assess which is the best way to go about this.

Thank you
Allen Brown
allen [at] qualica.com

Advertisement

andys

.NET Assembly

New assembly implemented and appears to be working fine. Not doing complicated transfer, but have got it transfering zip files between servers and checking results.

Thanks

singhgauravk
Joined:
Posts:
2

.NET Assembly Code

Hello, would it also be possible for me to get the DLL for testing purposes (email at singhgauravk At yahoo.com). Appreciate your help with this.
Thanks

Gaurav

singhgauravk
Joined:
Posts:
2

Re: Error: WinSCP. NET Assembly

martin wrote:

I have emailed you too.

Hey Martin,

Sorry to disturb you again, but I am stuck and would really appreciate if you could email me the files.
Thanks again!

Gaurav

pedonsito
Joined:
Posts:
1

assembly please

please, can you send me assembly by email.
fandres [at] gmail

Thanks you

Advertisement

techuser
Joined:
Posts:
1
Location:
United States

Would like to get beta of .NET assembly

I would like to get the beta of the .NET DLL. I have been trying to use the SFTP method as a process within VB.NET, and XML logging appears to work great when the username, password, etc. are correct. However, if I change any of these so that it fails, the XML logging does not seem to work correctly (just stops), and all I can retrieve is an error code of the process that it did not complete, but not any additional information as to why it didn't complete.

It is my hope that the .NET DLL being developed will be able to correctly provide detailed logging information such as bad username, bad password, unable to reach server,etc should a transmission not work. Something that would provide direction as to why the transmission failed.

Priti
Guest

.NET Assembly DLL

Can you please send me the .NET Assembly DLL as well???? Pleaseeeeeeeeeeeeeeeeeeee!!!! :)

Thanks!!
sandhupretty@hotmail.com

marcibme
Joined:
Posts:
1

Re: .NET Assembly

martin wrote:

I have sent a new version of the assembly to all of you.

Can you send it to marcibme[at]gmail.com as well?
Thanks a lot!

akenato82
Guest

.NET WinSCP dll

Hello, can I have WinSCP .NET assembly for try and test it!
Thanx a lot

Advertisement

akenato82
Guest

Re: .NET WinSCP dll

akenato82 wrote:

Hello, can I have WinSCP .NET assembly for try and test it!
Thanx a lot

My Email is nkmelil@gmail.com

martin
Site Admin
martin avatar

Re: Error: WinSCP. NET Assembly

WinSCP 5.0.6 beta, including the .NET assembly has been released already.

Priti
Guest

WinSCP on Production Server

Hi Martin, I have a question about WINSCP.

It is working perfectly fine on my local machine with my asp.net website. I installed Winscp and .net assembly as per the instructions on the production server also. But everytime I run a simple code for, lets say creating a connection to the remote Ssh server, it doesnt make any connection and following is the standardOutput:

winscp> open userID/Password/Host info .....Searching for host... Connecting to host... Authenticating... 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-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit

Can you please tell me what I am missing here?
Thanks,
sandhupretty@hotmail.com

Advertisement

Priti
Guest

WINSCP running on Server

Hi Jose, Follwing is the code(It's simply checking if user is authorised to login into the remote Ssh Server), It is working perfectly fine on my local machine......but when I run it on the production server, it is not detecting the host key.

Protected Function UnixServer_UserLoginAuthorization() As Boolean

Dim SessionOpen As Boolean
Dim iALPS_SessionOptions As New WinSCP.SessionOptions()

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With

Try
Using iALPS_Session As New WinSCP.Session
iALPS_Session.Open(iALPS_SessionOptions)

SessionOpen = iALPS_Session.Opened
iALPS_Session.Dispose()
End Using

Catch ex As Exception
Throw ex
SessionOpen = False
End Try

Return SessionOpen

End Function

The problem:

winscp> open userID:Password@Host info .....Searching for host... Connecting to host... Authenticating... 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-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

You've probably already checked this but is the UnixSshHostKey available on the server as well? Is it coming from some sort of cache that is only available on your local machine?

Examples:
ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
ssh-dss 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx

Also, is the dll the latest from the download? Mine has an Assembly/File version of 1.0.0.235.

Priti
Guest

WINSCP on the Production Server

Hey Jose, The Standard Output which I pasted in the previous post is from, when I run the website on the Production Server. And It does have the host key returned by the Ssh Server. (I checked it is the right Ssh Host Key for that server.)

After Installing WinSCP on the Production Server, when I connected to the remote Ssh Server manually through WINSCP.exe, It asked for the host key to be saved in some cache memory. I said YES!!! Why website is not recognising that key saved?

And the same steps done on my local machine running fine??

Thanks,
Priti

Priti
Guest

And yes I did install the latest Version Just yesterday :)

Advertisement

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Re: WINSCP on the Production Server

Priti wrote:

And the same steps done on my local machine running fine??
There are quite a few variables at play here. For example: Is your local machine and server both the same OS and do you have the same rights on both machines?

Have you considered hard coding the key into the code and attempting the connection?

Priti
Guest

WINSCP Production Server

Ok Local Machine and Server are different OS. Local is Windows XP and Server is Windows Server 2003 :|

Rights wise, what kind of rights specifically in respect to get WINSCP run through my asp.net site?

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With


UnixSshHostKey is hard coded for right now. Where I set the value for UnixSshHostKey in webConfig in application Settings and on pageload UnixSshHostKey has its hard coded value.
:?

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Re: WINSCP Production Server

Priti wrote:

Rights wise, what kind of rights specifically in respect to get WINSCP run through my asp.net site?
Not sure if you're just pulling it from the app settings. Just as a test try printing the results of the iALPS_SessionOptions.SshHostKey = UnixSshHostKey.ToString to a log or the web page with some sort of qualifier to make sure there isn't an issue.

Aside from that I'm not sure what to recommend.

Advertisement

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

Re: WinSCP on Production Server

Priti wrote:

winscp> open userID/Password/Host info .....Searching for host... Connecting to host... Authenticating... 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-d********the host key here*********** If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-host key here*******. Authentication failed. No session. winscp> exit
Please post a full log file showing the problem. (set Session.LogPath to enable logging).

Do not mask out the hostkey in the log. It would be useless then. Note that hostkey is public information anyway.

Priti
Guest

WINSCP on Production Server

Hello martin, thanks for replying :)

Following is the code and output.

Protected Function UnixServer_UserLoginAuthorization() As Boolean
Dim SessionOpen As Boolean

Dim iALPS_SessionOptions As New WinSCP.SessionOptions()

With iALPS_SessionOptions
.Protocol = Protocol.Sftp
.HostName = Machine.ToString
.UserName = UserID.ToString
.Password = Password.ToString
.SshHostKey = UnixSshHostKey.ToString
End With

Try
Using iALPS_Session As New WinSCP.Session
iALPS_Session.Open(iALPS_SessionOptions)
SessionOpen = iALPS_Session.Opened
iALPS_Session.Dispose()
End Using

Catch ex As Exception
Response.Write(ex)
SessionOpen = False
End Try

Return SessionOpen

End Function

The above function runs totally fine on my local machine, but gives the following output when I run it at Production Server. It waits for 3-4 minutes and then display the following:

System.TimeoutException: Timeout waiting for WinSCP to respond. at WinSCP.Session.CheckForTimeout() at WinSCP.Session.Open(SessionOptions sessionOptions) at _Default.UnixServer_UserLoginAuthorization() in D:\Pritpal\Test\Default.aspx.vb:line 154

Similarly if I run the following code on my loca Machine It runs fine with active connection to the remote server but not on the production Server. If there is some permission, Security or web.config/ Machine.config setting I need to change?

Dim UserOpenSessionString As String = "open " & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString
Dim SftpProcess As Process = New Process()
SftpProcess.StartInfo.FileName = "C:\Program Files\WinSCP\winscp.com"

SftpProcess.StartInfo.UseShellExecute = False
SftpProcess.StartInfo.RedirectStandardInput = True
SftpProcess.StartInfo.RedirectStandardOutput = True
SftpProcess.StartInfo.CreateNoWindow = True
SftpProcess.Start()

SftpProcess.StandardInput.WriteLine(UserOpenSessionString)
SftpProcess.StandardInput.WriteLine("exit")

SftpProcess.StandardInput.Close()

'Collect all output (not used in this example)
Dim output As String = SftpProcess.StandardOutput.ReadToEnd()

'Wait until WinSCP finishes
SftpProcess.WaitForExit()

This is the output when I run the above code on local machine. It runs fine.
"winscp> open UserID:Password@RemoteMachineName Searching for host... Connecting to host... Authenticating... Using username "UserID". Authenticating with pre-entered password. Authenticated. Starting the session... Reading remote directory... Session started. Active session: [1] UserID@RemoteMachineName winscp> exit "

The following is the output when I run this above sample code on the Production Server.

winscp> open UserID:Password@RemoteMachineName Searching for host... Connecting to host... Authenticating... 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 2048 26:e3:61:cf:57:8a:72:22:28:4c:aa:e1:cf:e6:b4:89 If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel. Continue connecting and add host key to the cache? (Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel Host key wasn't verified! Host key fingerprint is ssh-dss 2048 26:e3:61:cf:57:8a:72:22:28:4c:aa:e1:cf:e6:b4:89. Authentication failed. winscp> exit

Priti
Guest

Got it Working

Hey Martin, As recommended in your documentation, I had to hard code the Host Key in my code.

So looks like its working fine now.

Thanks,
Priti :)

Priti
Guest

tommyjon

The following worked for me....


"open sftp://" & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString & " -hostkey=" & """" & UnixSshHostKey.ToString & """"

Advertisement

martin
Site Admin
martin avatar

Re: tommyjon

Priti wrote:

"open sftp://" & UserID.ToString & ":" & Password.ToString & "@" & Machine.ToString & " -hostkey=" & """" & UnixSshHostKey.ToString & """"
I'm confused. You've claimed that you use the .NET assembly.

JustinK
Guest

Host key wasn't verified

I used the WinSCP .Net Assemble and wrote a VB script to transfer files.
However, I got a error message "Host key wasn't verified!".
My script is as following.
I have added the public key on remote server.
And the host key in the script is the finger print of the private key.
There is no problem if I use WinSCP GUI to connect to the remote server.
Could anyone help me to fix the issue?

Option Explicit

' Setup session options
Dim sessionOptions
Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions")
With sessionOptions
.HostName = "test.com"
.UserName = "test"
.Password = "password"
.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
End With

Dim session
Set session = WScript.CreateObject("WinSCP.Session")

' Connect
session.Open sessionOptions

' Upload files
Dim transferOptions
Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions")
'transferOptions.TransferMode = TransferMode.Binary

Dim transferResult
Set transferResult = session.PutFiles("c:\data\mylogfile.txt", ".", False, transferOptions)

' Throw on any error
transferResult.Check

' Print results
Dim transfer
For Each transfer In transferResult.Transfers
WScript.Echo "Upload of " & transfer.FileName & " succeeded"
Next

' Disconnect, clean up
session.Dispose

martin
Site Admin
martin avatar

Re: Host key wasn't verified

JustinK wrote:

And the host key in the script is the finger print of the private key.
SessionOptions.SshHostKey is fingerprint of server's public key (host key).

Advertisement

This topic is locked: you cannot edit posts or make replies