 |
|
 |
every time am trying to connect it crash and give me the error :
at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout) in D:\My Documents\Visual Studio 2008\Projects\WindowsFormsApplication2\WindowsFormsApplication2\sharpSsh.src\jsch\Session.cs:line 439
anyone can help?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Ok i've added :22 at the end of the IP and its working now... but while connect another error occurred :
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 92.242.144.5:22
although 92.242.144.5 is not my IP! i dont know what is it!
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
I downloaded the three projects Tamir.SSH, SecurityServices and DiffieHellman and compiled them to give me strongly-named assemblies. My project now references them and I get an error when I try to do sftp.Connerct(). How can this be fixed?
[Tamir.SharpSsh.jsch.JSchException] Session.connect: System.IO.FileLoadException: Could not load file or assembly 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) File name: 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
I expect that version 1.1.1.13 is loaded..
Thanks, Avanti
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I will be as brief, but comprehensive as possible. I have generated keys (OpenSSH format). I have tested a connection with WinSCP successfully. I deployed the dll into a .NET web app. I always get Auth fail exception. I am including the relevant lines of code below: Sub DoIt() ftp.host = "server.com" ftp.user = "username" ftp.pass = "password" ftp.path = "outbound/encrypted/" ftp.key = "D:\Private.ppk" ftp.phrase = "passphrase" Dim al as ArrayList = ftp.ListFilesSFTP 'OTHER STUFF HAPPENS HERE End Sub
Here is the FTP class/UserInfo interface/UserInfo class I am using: Imports Microsoft.VisualBasic Imports System Imports System.Threading Imports System.IO Imports System.Collections Imports Tamir.SharpSsh Imports Tamir.SharpSsh.jsch
Public Class sftp Dim _host, _user, _pass, _localfile, _remotefile, _path, _key, _phrase As String Dim MyJSch As JSch = New JSch Dim Sess As Tamir.SharpSsh.jsch.Session Dim MyUI As MyUserInfo ' Tamir.SharpSsh.jsch.UserInfo
'GETTER AND SETTER METHODS OMITTED FOR BREVITY, BUT EXIST FOR EACH STRING LISTED ABOVE
Sub PutFile() Dim scp As Tamir.SharpSsh.Scp = New Tamir.SharpSsh.Scp(_host, _user, _pass) Try scp.To(_localfile, _remotefile) Catch ex As Exception 'error End Try End Sub Sub GetFile() Dim scp As Tamir.SharpSsh.Scp = New Tamir.SharpSsh.Scp(_host, _user, _pass) Try scp.From(_remotefile, _localfile) Catch ex As Exception 'error this End Try End Sub
Sub GetFileSFTP() SFTPTransmit("get") End Sub Sub PutFileSFTP() SFTPTransmit("put") End Sub Sub RemFileSFTP() SFTPTransmit("rem") End Sub
Function ListFilesSFTP() As ArrayList Dim al As ArrayList If _key IsNot Nothing AndAlso _key <> "" Then MyJSch.addIdentity(_key) MyUI = New MyUserInfo(_pass) MyUI.setPassphrase(_phrase) Else MyUI = New MyUserInfo(_pass) End If Sess = MyJSch.getSession(_user, _host, 22) Sess.setUserInfo(MyUI) Try Sess.connect() Dim ch As Channel = Sess.openChannel("sftp") ch.connect() Dim c As ChannelSftp = ch al = c.ls(_path) ch.disconnect() Sess.disconnect() Catch ex As Exception al = New ArrayList al.Add(ex.Message) al.Add(_phrase) al.Add(_pass) al.Add(_key) End Try Return al End Function Private Sub SFTPTransmit(ByVal GetPut As String) If _key IsNot Nothing AndAlso _key <> "" Then MyJSch.addIdentity(_key) MyUI = New MyUserInfo(_pass) MyUI.setPassphrase(_phrase) Else MyUI = New MyUserInfo(_pass) End If Sess = MyJSch.getSession(_user, _host, 22) Sess.setUserInfo(MyUI) Sess.connect() Dim ch As Channel = Sess.openChannel("sftp") ch.connect() Dim c As ChannelSftp = ch Try Select Case GetPut Case "get" If File.Exists(_localfile) Then File.Delete(_localfile) End If c.get(_remotefile, _localfile) Case "put" c.put(_localfile, _remotefile) Case "rem" c.rm(_remotefile) End Select Catch ex As Exception Dim AP As APage = New APage AP.SendEmail("", "", "x@y.com", "y@z.com", "FTP EXCEPTION", False, ex.ToString, "", "") 'Dim db As DBOps = New DBOps 'db.ExecuteCmd("insert into table(log_slg,dtc_slg) values('" & GetPut & " - " & _remotefile & " - " & _localfile & "',getdate())") 'after checking this out, it turns out, the problem stemmed from the fact that the file already existed. End Try ch.disconnect() Sess.disconnect() End Sub End Class
Public Interface UserInfo Function getPassphrase() As String Function getPassword() As String Function promptPassphrase(ByVal message As String) As Boolean Function promptPassword(ByVal message As String) As Boolean Function promptYesNo(ByVal message As String) As Boolean Function showMessage(ByVal message As String) As Boolean End Interface
Public Class MyUserInfo Implements Tamir.SharpSsh.jsch.UserInfo Private pass As String Private phrase As String Public Sub New(ByVal pw As String) pass = pw phrase = "" End Sub
Public Function getPassword() As String Implements Tamir.SharpSsh.jsch.UserInfo.getPassword Return pass End Function
Public Sub setPassword(ByVal pw As String) pass = pw End Sub
Public Sub setPassphrase(ByVal pw As String) phrase = pw End Sub Public Function promptYesNo(ByVal message As String) As Boolean Implements Tamir.SharpSsh.jsch.UserInfo.promptYesNo Return True End Function Public Function getPassphrase() As String Implements Tamir.SharpSsh.jsch.UserInfo.getPassphrase Return phrase End Function Public Function promptPassphrase(ByVal message As String) As Boolean Implements Tamir.SharpSsh.jsch.UserInfo.promptPassphrase Return True End Function Public Function promptPassword(ByVal message As String) As Boolean Implements Tamir.SharpSsh.jsch.UserInfo.promptPassword Return True End Function Public Sub showMessage(ByVal message As String) Implements Tamir.SharpSsh.jsch.UserInfo.showMessage
End Sub End Class
I cannot determine what is wrong. I have checked the source, but I cannot see anything that would be incorrect, so I am guessing it is something in this small chunk of code, potentially the UserInfo part.
I will add that the top of my private key is (after the BEGIN line, obviously): Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,03F6260FEFC44343
And that may provide some guidance, I hope.
Any help would be greatly appreciated.
Thanks!
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
im working with tamirssh and try to upload a text file from 1 server to another server through SFTP, when i come to put method :
sshCp.Put(localFile, remoteFile);
i get 1 error like below : Exception of type 'Tamir.SharpSsh.jsch.SftpException' was thrown.
i havnt idea what is happening, i googled but seem like not solution found.
the dll version im using is 1.1.1.13
Can somebody help?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I have this basic code using a SshStream.... How can I login using a private DSA Key and not use a password.
SshStream ssh = new SshStream("host123", "user1", "password");
//Set the end of response matcher character ....This is for standard user ssh.Prompt = @"\[[^@]*@[^]]*]\$\s";
//Remove terminal emulation characters ssh.RemoveTerminalEmulationCharacters = true;
//MUST READ AFTER LOGIN to clear ssh.ReadResponse();
//Command to be captured ssh.Write("uptime");
//Reading from the SSH channel string response = ssh.ReadResponse(); ssh.Close();
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
For security reasons, I have port 22 set to blacklist on my server, how can I use SshStream to connect to a different port?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
All,
I need to grab the contents of the banner displayed prior to login. I have been sorting through the code, but still haven't been able to find the proper point to grab the contents. Any ideas?
Thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I've got a problem using SshShell class. In my application I execute some unix shell scripts which promts the user to change between yes or no, but at this point my application freezes.
Here is an example:
[...] PROG_LOG="test.log"
if [ ! -f $PROG_LOG ] then echo "This source hasn't been tested yet." echo -n "Do you wish to submit it without testing? (yes/[no]) " read SURE [ "$SURE" == "yes" ] || { echo "Submittion cancelled." ; exit 2 ; } else [...]
So this code would print to the screen: "This source hasn't been tested yet. Do you wish to submit it without testing? (yes/[no])" and waits still the user enters "YES" or "NO".
I use the SshShell class in my project, and when I read the following output of the command, my application freezes, and I can't do anything just kill the app and restart it to continue my work.
I try to translate my shell script to c# but it would be nice to find a solution to this problem, because in the future I don't want to edit the shell script and my application, too.
Please help me, it is very important for me, because this application is my degree work.
Thank you for your help.
Daniel Koós koos.daniel@gmail.com
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
I regularly use SharpSSH, and had to make a few changes and fixes (especially to support the GNU LSH). I would like to contribute to the project, but I couldn't contact Tamir Gal (in fact I could, but had no answer). So I suggest that we open a project on Google Code and carry on the good work started by Tamir Gal. We may also create a group Is there anyone here interested in contributing to the project?
Pascal.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
The problem is that I never got an answer from Tamir Gal, and forking a project is probably the last thing to do, but if we get no answer here, then forking is the "less worst" solution...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Sorry for not replying sooner. Unfortunately, due to lack of time and resources I can't support the ShapSSH project any longer. The project is currently hosted on sourceforge, if anyone is interested in continuing this project, please send me a PM. Thanks, Tamir
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I need to execute a sudo command which basically will stop and restart the server. I tried to send it using SshExec command but it seems never been executed. It should stop the server, restart it and until all result is OK, then I can close my ssh connection. Is anyone worked in the same case before?
Thanks.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hello. Thanks for great article and great library. I tried it on Windows XP machines and Vista and it worked excellent!!! But on Windows 7 machine I get message like this: Session.connect: System.Security.Cryptography.CryptographicException: Bad data.
в System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) в System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey) в System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters) в Tamir.SharpSsh.jsch.jce.SignatureDSA.verify(Byte[] sig) в Tamir.SharpSsh.jsch.DHG1.next(Buffer _buf) в Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)
but I don't use any keys, I just use login and password. Tell me please what can it be? (I know ssh protocol not very good)
Nitinur in vetitum semper, cupimusque negat!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello Tamir.
My name is Oscar and I develop software in Italy. I downloaded the software SharpSSH.
In my project I added the references to: DiffieHelllman.dll Org.Mentalis.Security.dll (Ver. 1.0.13.715) Tamir.SharpSSH.dll (ver. 1.1.1.13)
Language VB, framework 3.5 SP1.
With the following code contained in a class, I upload and download files
Imports Tamir.SharpSsh
Private sshCp As SshTransferProtocolBase
Private Function UpFile(ByVal Path As String, ByVal NumT As Integer) As Boolean Dim Origine As String Dim Destinazione As String
Try If mDLCartBase <> String.Empty Then Origine = mDLCartBase & "\" & Path Else Origine = Path End If If mSFCartBase <> String.Empty Then Destinazione = mSFCartBase & "/" & Path.Replace("\", "/") Else Destinazione = Path.Replace("\", "/") End If
sshCp.Put(Origine, Destinazione)
Return True Catch ex As Exception If NumT >= CInt(mVNumTent) Then DescErr = "Upload error. File " & Path & " : " & ex.Message
'Scrivo il file di LOG ScritturaLOG.LOG(LogUpErr, "Error", DescErr) End If
Return False End Try End Function
Private Function DownFile(ByVal SedeDest As String, ByVal SedeOrigine As String, ByVal Path As String, ByVal NumT As Integer) As Boolean Dim Origine As String Dim Destinazione As String
Try If mSFCartBase <> String.Empty Then Origine = mSFCartBase & "/" & Path.Replace("\", "/") Else Origine = Path.Replace("\", "/") End If If mDLCartBase <> String.Empty Then Destinazione = mDLCartBase & "\" & Path Else Destinazione = Path End If
sshCp.Get(Origine, Destinazione)
Return True Catch ex As Exception If NumT >= CInt(mVNumTent) Then DescErr = "Destination : " & SedeDest & " - Origin : " & SedeOrigine & ". Download error. File " & Path & " : " & ex.Message
'Scrivo il file di LOG ScritturaLOG.LOG(LogDownErr, "Error", DescErr) End If
Return False End Try End Function
Everything seems to work but not some JPG files. The upload is correct,instead the download creates an exception (Tamir.SharpSsh.jsch.SftpException).
I tried with your example console and it goes into error even in this case. Have you already happened? How did you solve the problem?
Thanks for your reply.
Oscar
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have a application that connects to a server and opens a tunnels:
session.setPortForwardingL(6, "localhost", 80); //(a http web server ).
I have noticed that when I starts the browser and opens: http://localhost:6 to get the page, if the first page is redirected to a second page the browser waits forever.
If I make the same connection and tunnel in putty or tunnelier then it works.
How can I fix this?
lms
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am trying to get list of files in a folder and download the files one by one, the .get method to download is not working, i don't get any errors, but the file is also not getting downloaded. The files gets deleted from the SSH server once the download is complete, the file is still there on the server, also i checked the download directory before download using lpwd to make sure the file download directory. Please Help!!! its urgent...
JSch jsch = new JSch(); Session session = jsch.getSession(sftpUserId, sftpServer, 22); UserInfo ui = new MyUserInfo(); session.setUserInfo(ui); System.Collections.Hashtable hash = new Hashtable(); hash.Add("StrictHostKeyChecking", "no"); session.setConfig(hash); session.connect(); Channel channel = session.openChannel("sftp"); channel.connect(); ChannelSftp c = (ChannelSftp)channel; c.lcd(downloadFilePath); ArrayList list = new ArrayList(); foreach (Tamir.SharpSsh.jsch.ChannelSftp.LsEntry entry in c.ls(sftpServerPath)) { list.Add(entry.getFilename().ToString()); } c.cd(sftpServerPath); try { foreach(string file in list) { if (!(file.Equals(".") || file.Equals(".."))) { c.get(file); } } } catch (Exception exception) { Tamir.SharpSsh.jsch.SftpException exceptionTamir = (Tamir.SharpSsh.jsch.SftpException)exception; } session.disconnect();
}
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
I'm using the SshShell object as follows:
Imports Tamir.SharpSsh
Dim ssh As SshShell
ssh = New SshShell(FTPServerID, Me.txtLogin.Text.Trim, Me.txtPassword.Text)
theBool = False x = 1
Try ssh.Connect()
ssh.Write(vbNewLine) ssh.Write("/home/dmadmin/custom/scripts/t2e_authentication/run_auth " & ssh.Username & vbNewLine)
Do While (Not theBool)
outStr = ssh.Expect() If outStr.Contains("TRUE") Or outStr.Contains("FALSE") Then theBool = True Else MsgBox("Try " + x.ToString + ": " + outStr) End If
x += 1 Loop
ssh.Close()
If Not theBool Then
MsgBox("EDMS Authentication failed. Please check the docbase or call 412-374-3339 for assistance.", MsgBoxStyle.Critical) Cleanup(False) Exit Sub End If Catch ex As NullReferenceException MsgBox("didn't work") End Try
========================================================================
I'm using it to execute a wrapper script that will determine if the user has access to this area or not. The problem is that the ssh doesn't let me do this! This is my wrapper script:
#!/bin/csh
echo $1
whoami $DM_HOME/bin/dmbasic -f /home/dmadmin/custom/scripts/t2e_authentication/authentication.bas -eMaine -p$1
======================================================================= Here's what happens: It prints the user's name via the 'echo' but when it encounters the whoami command it says 'Command not found' and for my $DM_HOME variable is says 'Undefined variable'.
Here's where it gets interesting...if I do an rsh from another unix box to the unix box this program connects to and run the same script, it works.
Example: rsh neptune "/home/dmadmin/custom/scripts/t2e_authentication/run_auth crittedp"
Output:
crittedp dmadmin TRUE
Any ideas?!?!
PS - I'm using VB .net 2005
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Why does it take so long to open a sshExec connection? Other types of connections seem to be fine.
Edit: It seems to be almost 15 seconds per connection. At the moment my app creates 3 connections on launch, even though this is done on a separate thread it still means almost a minute before my app can do anything
modified on Wednesday, April 15, 2009 12:46 AM
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
i have the same exception as in a previous message here : System.NullReferenceException: Object reference not set to an instance of an object. at Tamir.SharpSsh.jsch.ChannelSftp._put(InputStream src, String dst, SftpProgressMonitor monitor, Int32 mode) at Tamir.SharpSsh.jsch.ChannelSftp.put(String src, String dst, SftpProgressMonitor monitor, Int32 mode) at Tamir.SharpSsh.Sftp.Put(String fromFilePath, String toFilePath)
In the context of my project, it happens only when i send 2 files at a time but from different threads...the weird thing is that happens maybe 10 minutes after the beginning of the 2nd transfer. And that is the first transfer, which is crashing, letting the second run without problem.
Could it be a 'shared' ressources problem or something related to multithreading?
It's obviously not a firewall problem or anything like it because if there's only one file the transfer is going well (even with 20 GO file, just so that u know, pretty impressive).
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
I've been using this Tamir SSH code for over a year, probably longer, on multiple machines of various operating systems
On the 9th of March 2009, several machines got several Microsoft Automatic upgrades, KB 958484, KB 958481 and KB 958483. They appear to be DotNet patches, mostly due to the bugs in the DotNet 3.5 SP 1 (Our stuff is in 2.0, so you'd think problems in 3.5 would NOT affect it... anyway...)
Since then, the SSH connects fine, the ports appear to be there, but anything that tries to USE those connections fails (It's as if they just aren't there, fails are instant)
Rolling back prior to those patches on affected machines fixes the problem. However we can't roll back on all machines, and regardless, it's likely we will need to patch those machines at SOME stage.
Anyone seen anything like this?
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
This is a very longshot, but you're not using "localhost" to refer to the local machine, are you? If you are, try "ping localhost" to see whether it's using the IPv6 resolution (::1) or IPv4 (127.0.0.1). Something has either changed my Hosts file to "::1 localhost" or has somehow broken resolution from IPv4 apps (I'm guess a recent Microsoft patch). Anyway; try pinging localhost and, if it resolves to ::1, change your hosts file to "127.0.0.1 localhost"
S.
|
| Sign In·View Thread·PermaLink | 2.50/5 (2 votes) |
|
|
|
 |
|
 |
Any one of your having problem with the .Get method?
I am trying this library on 1 of my Windows 2008, after it downloaded the file, it looped and re-download the same file again, 3rd time and forth...
Any one came across this?
Thanks
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |