bachsio / ganymed-ssh-2 Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/ganymed-ssh-2
License: Other
Automatically exported from code.google.com/p/ganymed-ssh-2
License: Other
When using ch.ethz.ssh2.Connection.createLocalPortForwarder(int local_port,
String host_to_connect, int port_to_connect), it is possible to specify an
ephemeral port by using local_port=0. However, once the socket is bound, there
is no way to identify what the resulting ephemeral port is.
Example code (based on examples/PortForwarding.java):
------------------
// Create a LocalPortForwarder using an ephemeral port,
// i.e. local_port = 0 means "Choose an open port."
LocalPortForwarder lpf1 = conn.createLocalPortForwarder(0, "www.ethz.ch", 80);
// An ephemeral port has now been created, but there is no way
// to find out what it is.
// netstat -an | grep
------------------
Proposed API changes:
* Add method to LocalPortForwarder which returns the InetSocketAddress created
by the ServerSocket.bind(...) call.
-------------
InetSocketAddress LocalPortForwarder.getLocalSocketAddress()
-------------
What version of the product are you using? On what operating system?
* Ganymed-ssh-2 r46
https://code.google.com/p/ganymed-ssh-2/source/browse/trunk?r=46
* Windows 8 (64-bit)
* OpenJDK 1.6
--------------
$ $JAVA_HOME/bin/java -version
openjdk version "1.6.0-OpenSCG-Build-24"
OpenJDK Runtime Environment (build 1.6.0-OpenSCG-Build-24-b1)
OpenJDK Client VM (build 20.0-b12, mixed mode)
--------------
Original issue reported on code.google.com by [email protected]
on 16 Jul 2013 at 9:15
Need a new API which would change the dimensions of the terminal window.
Whenever the user or application changes the size of the terminal window, using
this API one should be able to change the terminal dimensions.
Original issue reported on code.google.com by [email protected]
on 29 Jun 2011 at 9:11
What steps will reproduce the problem?
1. Have an SFTP server up and running that only allows writing files, but not
reading files (i.e., SSH_FXF_CREAT and SSH_FXF_WRITE is allowed, but not
SSH_FXF_READ)
2. Open a connection using new SFTPv3Client(sshConnection);
3. Try to create a file using SFTPv3Client.createFile(fileName)
What is the expected output? What do you see instead?
Expected: File gets created and can subsequently be written to.
Actual: The following stacktrace:
ch.ethz.ssh2.SFTPException: File not found (SSH_FX_NO_SUCH_FILE: A reference was made to a file which does not exist.)
at ch.ethz.ssh2.SFTPv3Client.openFile(SFTPv3Client.java:1198)
at ch.ethz.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1071)
at ch.ethz.ssh2.SFTPv3Client.createFile(SFTPv3Client.java:1052)
What version of the product are you using? On what operating system?
ganymed-ssh2-build251beta1, java7, ubuntu linux
Please provide any additional information below.
SFTPv3Client.createFile(String fileName, SFTPv3FileAttributes attr) opens a file as following:
return openFile(fileName, 0x00000008 | 0x00000003, attr); // SSH_FXF_CREAT | SSH_FXF_READ | SSH_FXF_WRITE
The flags to be used should be configurable, not hard-coded.
Original issue reported on code.google.com by [email protected]
on 11 Jan 2012 at 10:11
What steps will reproduce the problem?
1. create a session using connection object, execute some command and close the
session
2. create new session using same connection object, execute some command and
close the session
3. do the same
What is the expected output? What do you see instead?
There are should be IOException in connection object while opening a new
session. new session should be created successfully
What version of the product are you using? On what operating system?
251
Please provide any additional information below.
java.io.IOException: Sorry, this connection is closed.
at ch.ethz.ssh2.transport.TransportManager.sendMessageImmediate(TransportManager.java:792)
at ch.ethz.ssh2.transport.TransportManager.sendMessage(TransportManager.java:765)
at ch.ethz.ssh2.channel.ChannelManager.openSessionChannel(ChannelManager.java:621)
at ch.ethz.ssh2.Session.<init>(Session.java:42)
at ch.ethz.ssh2.Connection.openSession(Connection.java:1097)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.doCollection(NasServerConnection.java:317)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.collectData(NasServerConnection.java:294)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.getNasClusterData(NasServerConnection.java:283)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.getValue(NasServerConnection.java:567)
at com.ericsson.monitoring.plugin.nascluster.NasClusterMeasurement.getValue(NasClusterMeasurement.java:29)
at org.hyperic.hq.product.MeasurementPluginManager.getPluginValue(MeasurementPluginManager.java:171)
at org.hyperic.hq.product.MeasurementPluginManager.getValue(MeasurementPluginManager.java:269)
at org.hyperic.hq.measurement.agent.server.ScheduleThread.getValue(ScheduleThread.java:438)
at org.hyperic.hq.measurement.agent.server.ScheduleThread.access$1500(ScheduleThread.java:76)
at org.hyperic.hq.measurement.agent.server.ScheduleThread$MetricTask.run(ScheduleThread.java:505)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.InterruptedIOException
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at ch.ethz.ssh2.crypto.cipher.CipherOutputStream.flush(CipherOutputStream.java:80)
at ch.ethz.ssh2.transport.TransportConnection.sendMessage(TransportConnection.java:195)
at ch.ethz.ssh2.transport.TransportConnection.sendMessage(TransportConnection.java:109)
at ch.ethz.ssh2.transport.TransportManager.sendMessageImmediate(TransportManager.java:813)
at ch.ethz.ssh2.transport.TransportManager.sendMessage(TransportManager.java:765)
at ch.ethz.ssh2.channel.ChannelManager.closeChannel(ChannelManager.java:354)
at ch.ethz.ssh2.Session.close(Session.java:453)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.nasServiceOnlineCount(NasServerConnection.java:860)
at com.ericsson.monitoring.plugin.nascluster.NasServerConnection.doCollection(NasServerConnection.java:304)
... 15 more
Original issue reported on code.google.com by [email protected]
on 10 Oct 2013 at 2:05
SSH Server version: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
Ganymed release: ganymed-ssh2-262.jar
Client platform: Slackware 14.1
Hi all,
I'am using the Connection.connect method with timeouts (connectTimeout and
kexTimeout == DEFAULT_CONNECT_TIMEOUT == 10000).
public void myConnect(String dst, int port, String user, String passwd) {
try {
this.connection = new Connection(dst, port);
ConnectionMonitor cmon = new ConnectionMonitor() {
@Override
public void connectionLost(Throwable cause) {
System.out.println("connection lost: " + cause.toString());
}
};
this.connection.addConnectionMonitor(cmon);
System.out.println("connecting... " + user + "@" + dst + ":" + port);
connection.connect(null, DEFAULT_CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT); // <---
System.out.println("connected");
System.out.println("authenticating...");
boolean isAuthenticated = connection.authenticateWithPassword(user, passwd);
if (isAuthenticated == false) {
System.out.println("authentication failed");
} else {
System.out.println("authenticated");
}
} catch (IOException e) {
e.printStackTrace();
}
}
after connection establishment, I send a command
public void myExecCommand(String cmd) {
try {
if (connection == null) {
return;
}
Session session = connection.openSession();
session.execCommand(cmd);
InputStream stdout = new StreamGobbler(session.getStdout());
InputStream stderr = new StreamGobbler(session.getStderr());
BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(stdout));
BufferedReader stderrReader = new BufferedReader(new InputStreamReader(stderr));
while (true) {
String line = stdoutReader.readLine();
if (line == null) {
stdoutReader.close();
break;
}
System.out.println(line);
}
while (true) {
String line = stderrReader.readLine();
if (line == null) {
stderrReader.close();
break;
}
System.out.println(line);
}
System.out.println("exit status: " + session.getExitStatus());
session.close();
} catch (IOException e) {
e.printStackTrace();
}
}
command get executed successfully, then I wait for 1 minute, connection stays
up for 9.something sec then connectionLost() is called, this is the output:
connection lost: java.net.SocketTimeoutException: Read timed out
SSHD debug log below and tcpdump show that is the client that closes the
connection.
Looks like the connect timeout fired. Am I missing something obvious here
(which is
quite possible :-))? Bug?
thank you
ciao
FF
PS
if I do *not* send any command connection stays up
--- sshd debug output ---
debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type ECDSA
debug1: private host key: #2 type 3 ECDSA
debug1: could not open key file '/etc/ssh/ssh_host_ed25519_key': No such file
or directory
Could not load host key: /etc/ssh/ssh_host_ed25519_key
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='8888'
Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 8888 on 0.0.0.0.
Server listening on 0.0.0.0 port 8888.
debug1: Bind to port 8888 on ::.
Server listening on :: port 8888.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from 127.0.0.1 port 44864 on 127.0.0.1 port 8888
debug1: Client protocol version 2.0; client software version Ganymed_262
debug1: no match: Ganymed_262
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: permanently_set_uid: 33/33 [preauth]
debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: client->server aes128-ctr hmac-sha1-96 none [preauth]
debug1: kex: server->client aes128-ctr hmac-sha1-96 none [preauth]
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received [preauth]
debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user tnc service ssh-connection method none
[preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: userauth-request for user tnc service ssh-connection method password
[preauth]
debug1: attempt 1 failures 0 [preauth]
Accepted password for tnc from 127.0.0.1 port 44864 ssh2
debug1: monitor_child_preauth: tnc has been authenticated by privileged process
debug1: monitor_read_log: child log fd closed
User child is on pid 2645
debug1: permanently_set_uid: 1003/100
debug1: Entering interactive session for SSH2.
debug1: server_init_dispatch_20
debug1: server_input_channel_open: ctype session rchan 100 win 196608 max 32768
debug1: input_session_request
debug1: channel 0: new [server-session]
debug1: session_new: session 0
debug1: session_open: channel 0
debug1: session_open: session 0: link with channel 0
debug1: server_input_channel_open: confirm session
debug1: server_input_channel_req: channel 0 request exec reply 1
debug1: session_by_channel: session 0 channel 0
debug1: session_input_channel_req: session 0 req exec
Starting session: command for tnc from 127.0.0.1 port 44864
debug1: Received SIGCHLD.
debug1: session_by_pid: pid 2646
debug1: session_exit_message: session 0 channel 0 pid 2646
debug1: session_exit_message: release channel 0
debug1: session_by_channel: session 0 channel 0
debug1: session_close_by_channel: channel 0 child 0
debug1: session_close: session 0 pid 0
debug1: channel 0: free: server-session, nchannels 1
Connection closed by 127.0.0.1 // <--------
debug1: do_cleanup
Transferred: sent 3144, received 928 bytes
Closing connection to 127.0.0.1 port 44864
Original issue reported on code.google.com by [email protected]
on 23 Aug 2014 at 5:56
Would it be possible for you to post a working example of placing a file on a
remote server using the SCPClient class? I have been unsuccessful in getting
that working. I keep ending up with an empty file on my server that is not
named as I would expect it.
Here is a gist on GitHub that shows my code and what I get etc.
https://gist.github.com/michaelrice/26cd4c2fedd68b1a6a73
I am using build 262, and this is being used from a Grails application.
Original issue reported on code.google.com by [email protected]
on 11 May 2014 at 7:35
Using build 261 and getting the following exception.
cd: cwd=/home/campbell/outgoing/to_xsb/test
put: absPath=/home/campbell/outgoing/to_xsb/test/f1
numBytesRead=7, offset=0
numBytesRead=-1, offset=7
put: absPath=/home/campbell/outgoing/to_xsb/test/f2
Exception in thread "main" java.io.IOException: The server sent an invalid id
field.
at ch.ethz.ssh2.SFTPv3Client.openFile(SFTPv3Client.java:1233)
at ch.ethz.ssh2.SFTPv3Client.createFileTruncate(SFTPv3Client.java:1148)
at ch.ethz.ssh2.SFTPv3Client.createFileTruncate(SFTPv3Client.java:1129)
at sftp.put(sftp.java:59)
at sftp.main(sftp.java:106)
Test code is attached.
Original issue reported on code.google.com by [email protected]
on 25 Oct 2013 at 4:23
Attachments:
What is the reasoning to use ISO8859-1 by default to encode strings in the
protocol? I can't find any reference in the RFC.
Original issue reported on code.google.com by [email protected]
on 28 May 2011 at 9:39
[deleted issue]
In SFTP protocol version 4.
Original issue reported on code.google.com by [email protected]
on 6 Jun 2011 at 5:39
Recent versions of OpenSSH server have removed hmac-sha1 from the default MACs.
Recent versions of PuTTY, ConnectBot, and the OpenSSH client can connect to
such a server. Ghost Commander (which uses ganymed-ssh-2) can't connect to a
server without hmac-sha1, and its author said that this problem happens with
Basic.java too:
https://sourceforge.net/p/ghostcommander/bugs/33/
Should be reproducible with an OpenSSH 6.6 running with defaults, or 6.0 (what
Debian ships) with the following line in sshd_config:
MACs hmac-sha2-256,hmac-sha2-512
Original issue reported on code.google.com by [email protected]
on 28 Apr 2014 at 6:32
[deleted issue]
The SCPInputStream class keeps track of the number of remaining bytes. In
method read() (the one without arguments), the line
remaining -= read;
should really be
remaining--;
In most cases, this causes files read using SCPInputStream's read() method to
end prematurely.
Original issue reported on code.google.com by [email protected]
on 11 Mar 2014 at 2:39
What steps will reproduce the problem?
1.I am trying to setup a SSH connection to SUN OS machine using the API
connection.authenticateWithPassword.
What is the expected output? What do you see instead?
The expected output is that the SSH connection setup should go fine. Instead I
am getting the below exception
The connection setup fails with below exception
java.io.IOException: Password authentication failed.
at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:336)
at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:322)
What version of the product are you using? On what operating system?
ganymed version is ganymed-ssh2-build210.zip. The problem is occurring on the
machine with SUN OS
Original issue reported on code.google.com by [email protected]
on 13 Dec 2013 at 9:40
In the same as a Socket has a bind method for the local (source) ip address,
this would be appreciated if implemented in the ch.ethz.ssh2.Connection class.
Attached is an example implementation of such an bindSourceAddress method.
Original issue reported on code.google.com by [email protected]
on 4 Feb 2014 at 12:16
Attachments:
What steps will reproduce the problem?
1. create and open session, execute long running remote command
2. kill sshd on target server (or unplug network wire.. force/simulate lost
connection/process)
3. Read completes with no exception or indication of error
What is the expected output? What do you see instead?
Some form of failure, probably IOException
What version of the product are you using? On what operating system?
build210, linux(ubuntu) client and server
Please provide any additional information below.
Issue is in Thread created in TransportManager.initialize. IOExceptions causing
drop out of the receiveLoop are caught, tm.close is called, logged, and
discarded.
While close() records the exception as a cause, this is within the
TransactionManager which is not accessable to client code.
IOException should probably be thrown from this code, or worst case provide
some way to access the TransactionManager.reasonClosedCause from client code.
Original issue reported on code.google.com by [email protected]
on 27 May 2011 at 6:55
For symmetry with addConnectionMonitor(), please add a
removeConnectionMonitor() method, so I don't have to get connectionLost()
events when I close my own connection.
Semantics:
1. addConnectionMonitor() should throw NPE if monitor is null.
2. addConnectionMonitor() should throw IllegalArgumentException if monitor
already exists.
3. removeConnectionMonitor() should throw IllegalArgumentException if the
monitor doesn't already exist in the list. Note that this case also covers the
case where the monitor to remove is null.
Original issue reported on code.google.com by [email protected]
on 20 Jun 2012 at 1:38
What is the minimum runtime to target? Java 1.5?
Original issue reported on code.google.com by [email protected]
on 27 May 2011 at 9:33
The SSHD 'ClientALive' feature works by sending an SSH_MSG_CHANNEL_REQUEST for
an arbitrary channel with an arbitrary request-type string consisting of the
server name. The idea is that the client responds with an
SSH_MSG_CHANNEL_FAILURE message, indicating that the client didn't understand
the request type. Receipt of this reply indicates to the server that the client
is still there and hence still alive. However Ganymede doesn't implement this.
Instead, in ChannelManager, it throws an IOException "Unexpected
SSH_MSG_CHANNEL_REQUEST message for non-existent channel [xyz]":
int id = tr.readUINT32();
Channel c = getChannel(id);
if (c == null)
throw new IOException("Unexpected SSH_MSG_CHANNEL_REQUEST message for non-existent channel " + id);
which eventually closes the *entire connection.* This is the dead opposite of
the correct behaviour. The reason for this problem is that it validates the
channel number before validating the request type.
Can this please be fixed, it is mission-critical for us. It seems like a pretty
simple fix.
See http://osdir.com/ml/ietf.secsh/2002-01/msg00006.html for a discussion.
Original issue reported on code.google.com by [email protected]
on 17 Jun 2012 at 10:42
Currently logging is disabled. Introduce dependency to log4j or similar?
Original issue reported on code.google.com by [email protected]
on 27 May 2011 at 1:21
When SSH server sends data with zero payload - SSH_MSG_CHANNEL_DATA message
with length 9 the Ganymed client throws an exception and disconnects
A data message with zero payload should be handled and silently discarded.
Instead, the msgChannelData function will throw an IOException
"SSH_MSG_CHANNEL_DATA message has wrong size (" 9 ")". The client then
disconnects
SSH-2.0-Ganymed_261
OS X 10.9.1
The Ganymed client check the length of SSH data message when it is received.
When the SSH server send a data packet with zero payload, which is apparently
ok with the RFC, the Ganymed SSH client receive thread throws an exception that
cause a disconnect.
The ChannelManager msgChannelData() lengh check should be msglen < 9, not
msglen ≤9 as data packets without payload are not forbidden by the SSH
Connection Protocol RFC.
Original issue reported on code.google.com by [email protected]
on 9 Jan 2014 at 9:13
Attachments:
Could we please put the javadocs online, such as on GitHub?
We could link to the javadocs from the ganymed home page.
Original issue reported on code.google.com by [email protected]
on 27 Nov 2013 at 4:14
I would like to see whether there is potential to migrate the project from svn
to Git?
The reasoning being that is might make it easier for working with other forks
of the project and pulling changes back in?
Original issue reported on code.google.com by [email protected]
on 21 Feb 2014 at 6:33
[deleted issue]
What steps will reproduce the problem?
1. login to session
2. close the session
3.
What is the expected output? What do you see instead?
SSH_MSG_DISCONNECT is expected at server side to confirm the client connection
close
What version of the product are you using? On what operating system?
210 and Linux
Please provide any additional information below.
SSH_MSG_DISCONNECT is declared in the Packets.java class and never used in
Session.
Original issue reported on code.google.com by [email protected]
on 10 Jun 2013 at 11:38
I'm trying to use the URL class to help extract the different parts of scp://
urls. But when I try to construct a URL, Java complains MalformedURLException:
unknown protocol: scp.
Could ganymed register scp:// as a valid URL protocol, so that libraries that
use ganymed will be able to use scp:// URLs?
http://www.reddit.com/r/java/comments/1rl4hp/how_do_i_register_scp_as_a_valid_ur
l_protocol/
Original issue reported on code.google.com by [email protected]
on 27 Nov 2013 at 6:16
The issue concerned was incorrectly closed for reasons which have been refuted.
Original issue reported on code.google.com by [email protected]
on 2 Nov 2013 at 2:48
I have a problem when I try to use more than one connection. I have an object
that creates multiple other objects, the second object has the code that uses
the ganymed project. If I only use one of the second object it will connect
prefectly with no issues. If I use more than one then the first one will
connect and login, with no issues. When the second one starts to initialize it
prints the error to the console, then instead of using its own connection it
uses the first one, it will over-ride the connection of the first one and then
login to the second device. This occurs with any number of connections and the
last one is the only one that is actually connected.
What steps will reproduce the problem?
1. Using more than one connection will always reproduce the error.
2.
3.
What is the expected output? What do you see instead?
Since the connection is in an instance of an object each connection should be
separate and independant.
What version of the product are you using? On what operating system?
I don't know how to check the version of the project that I have. I am using
Windows XP.
Please provide any additional information below.
Exception in thread "Thread-2" java.lang.IllegalStateException: Connection is
already authenticated!
at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:326)
at lister.SetupConnection(lister.java:208)
at lister.run(lister.java:29)
at java.lang.Thread.run(Unknown Source)
Original issue reported on code.google.com by [email protected]
on 17 Jan 2014 at 6:14
Hi,
I needed a method to put data from an InputStream on the SSH-Server. I added a
method to SCPClient.java which allows to put a file from an InputStream to the
server. Maybe it will be useful for you, too.
Here is the method I've added:
/**
* Copy a data from an InputStream to a remote directory, uses mode
* 0600 when creating the file on the remote side.
*
* @param is
* InputStream, ready to read data.
* @param length
* Amount of data which will be read from the stream.
* @param remoteFileName
* Remote file name.
* @param remoteTargetDirectory
* Remote target directory. Use an empty string to specify the default directory.
*
* @throws IOException
*/
public void put(InputStream in, long length, String remoteFileName, String remoteTargetDirectory) throws IOException {
byte [] buffer = new byte[8192];
Session sess = conn.openSession();
String cmd = "scp -t -d " + remoteTargetDirectory;
OutputStream os = new BufferedOutputStream(sess.getStdin(), 40000);
InputStream is = new BufferedInputStream(sess.getStdout(), 512);
remoteTargetDirectory = remoteTargetDirectory.trim();
remoteTargetDirectory = (remoteTargetDirectory.length() > 0) ? remoteTargetDirectory : ".";
try
{
String cline = "C0660" + " " + length + " " + remoteFileName + "\n";
sess.execCommand(cmd);
os.write(StringEncoder.GetBytes(cline));
os.flush();
readResponse(is);
try {
long remain = length;
while (remain > 0)
{
int trans;
if(remain > buffer.length) {
trans = buffer.length;
} else {
trans = (int) remain;
}
int readed = in.read(buffer, 0, trans);
if(readed <= 0) {
throw new IOException("Cannot read enough from external stream");
}
os.write(buffer, 0, readed);
os.flush();
remain -= readed;
}
}
finally {
if (in != null) {
in.close();
}
}
os.write(0);
os.flush();
readResponse(is);
os.write(StringEncoder.GetBytes("E\n"));
os.flush();
}
catch (IOException e) {
throw (IOException) new IOException("Error during SCP transfer.").initCause(e);
}
finally {
if (sess != null) {
sess.close();
}
}
}
Original issue reported on code.google.com by [email protected]
on 30 Sep 2011 at 7:18
java.io.IOException: Illegal sftp packet len: 34025
at ch.ethz.ssh2.SFTPv3Client.receiveMessage(SFTPv3Client.java:245)
at ch.ethz.ssh2.SFTPv3Client.scanDirectory(SFTPv3Client.java:724)
at ch.ethz.ssh2.SFTPv3Client.ls(SFTPv3Client.java:927)
at com.alphait.features.integration.hrm.HrmSFTPManager.listRemoteFiles(HrmSFTPManager.java:463)
Original issue reported on code.google.com by [email protected]
on 25 Aug 2014 at 7:41
Provide build with Ant or Maven.
Original issue reported on code.google.com by [email protected]
on 27 May 2011 at 1:20
This is an enhancement request and not an issue per se.
The goal is to make resource management easier.
Writing e.g. the following should be possible:
try (SFTPv3Client client = new SFTPv3Client(new Connection("localhost"))) {
}
AutoClosable should also be implemented by classes such as SFTPv3FileHandle.
http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html
http://www.oracle.com/technetwork/articles/java/trywithresources-401775.html
Original issue reported on code.google.com by [email protected]
on 12 Apr 2014 at 4:02
As i connect through putty it connects as follows
login as:xxxxxxx
(Cisco Controller)
User:xxxxxx
Password:xxxxxxxxx
I think
Thanks
Zahid
Original issue reported on code.google.com by [email protected]
on 17 Mar 2014 at 8:52
What steps will reproduce the problem?
1. Application initiates connection to server and performs some operations via
SFTP.
2. Server goes to hardware reboot
3. Thread that expects answer hangs on SocketRead0
In thread dump:
"Thread-3" daemon prio=1 tid=0x46e11698 nid=0x6ee runnable
[0xbadff000..0xbadff654]
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)at
ch.ethz.ssh2.crypto.cipher.CipherInputStream.fill_buffer(CipherInputStream.java:
41)
at
ch.ethz.ssh2.crypto.cipher.CipherInputStream.internal_read(CipherInputStream.jav
a:52)
at
ch.ethz.ssh2.crypto.cipher.CipherInputStream.getBlock(CipherInputStream.java:79)
at ch.ethz.ssh2.crypto.cipher.CipherInputStream.read(CipherInputStream.java:108)
at
ch.ethz.ssh2.transport.TransportConnection.receiveMessage(TransportConnection.ja
va:231)
at
ch.ethz.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:680)at
ch.ethz.ssh2.transport.TransportManager$1.run(TransportManager.java:468)at
java.lang.Thread.run(Thread.java:595)
I've found connection estimation code:
private void establishConnection(ProxyData proxyData, int connectTimeout) throws IOException
{
/* See the comment for createInetAddress() */
if (proxyData == null)
{
InetAddress addr = createInetAddress(hostname);
sock.connect(new InetSocketAddress(addr, port), connectTimeout);
sock.setSoTimeout(0); // <----- !!!!
return;
}
if (proxyData instanceof HTTPProxyData)
{
HTTPProxyData pd = (HTTPProxyData) proxyData;
/* At the moment, we only support HTTP proxies */
InetAddress addr = createInetAddress(pd.proxyHost);
sock.connect(new InetSocketAddress(addr, pd.proxyPort), connectTimeout);
sock.setSoTimeout(0); // <----- !!!!
It is a good idea to allow to tune SO_TIMEOUT for application that uses a
connection.
Tried it with:
ganymed-ssh2-build251beta1.zip
You can also contact me for additional information.
Original issue reported on code.google.com by [email protected]
on 22 Nov 2011 at 9:25
What steps will reproduce the problem?
Try to connect to server with long login banner
What is the expected output? What do you see instead?
Expected: success connection
Instead:
[11/28/10 22:30:12] [SSH] Opening SSH connection to XXXXXXXXXXXXXXXXXXXXXXX:22.
java.io.IOException: There was a problem while connecting to
XXXXXXXXXXXXXXXXXXXXXXXXXX:22
at com.trilead.ssh2.Connection.connect(Connection.java:755)
at com.trilead.ssh2.Connection.connect(Connection.java:546)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:523)
at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:179)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:184)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: The server sent a too long line.
at
com.trilead.ssh2.transport.ClientServerHello.readLineRN(ClientServerHello.java:5
1)
at
com.trilead.ssh2.transport.ClientServerHello.<init>(ClientServerHello.java:68)
at
com.trilead.ssh2.transport.TransportManager.initialize(TransportManager.java:457
)
at com.trilead.ssh2.Connection.connect(Connection.java:699)
... 9 more
What version of the product are you using? On what operating system?
version 260, All OS
Please provide any additional information below.
Please increase serverVersion array size to 1024 in ClientServerHello:66
byte[] serverVersion = new byte[1024];
Original issue reported on code.google.com by [email protected]
on 5 Aug 2011 at 9:46
We had a query related to the usage of ganymed API’s. In the below code
snippet once the authentication to ssh server is
done(some_user,some_password,some_sshServer) ,the below steps are done
connection.openSession();
session.requestPTY("xterm");
session.execCommand(“some command”);
Is this equivalent to doing ssh as below
ssh –t –t some_user@some_sshServer “some_command”
If this does not result in addition of –t –t , then what other steps needs
to be followed?
Ganymed release:ganymed-ssh2-build210.zip
Original issue reported on code.google.com by [email protected]
on 19 May 2014 at 5:28
Provide version numbering scheme for upcoming releases. Currently handled in
`builddistro.sh`.
Original issue reported on code.google.com by [email protected]
on 27 May 2011 at 1:20
conn = new Connection(Ip);
boolean result;
try {
conn.connect(null,1000,0);
result = conn.authenticateWithPassword(userId, password);
}catch (IOException e) {
conn.close();
return null;
}
When the program executes the method conn.authenticateWithPassword then
blocked。
jstack info:
"main" prio=6 tid=0x0067c400 nid=0x1974 in Object.wait() [0x00fff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x23c00660> (a java.util.Vector)
at java.lang.Object.wait(Object.java:503)
at ch.ethz.ssh2.auth.AuthenticationManager.deQueue(AuthenticationManager.java:82)
- locked <0x23c00660> (a java.util.Vector)
at ch.ethz.ssh2.auth.AuthenticationManager.getNextMessage(AuthenticationManager.java:99)
at ch.ethz.ssh2.auth.AuthenticationManager.initialize(AuthenticationManager.java:135)
at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:267)
at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:309)
- locked <0x23bf9450> (a ch.ethz.ssh2.Connection)
Original issue reported on code.google.com by [email protected]
on 7 Feb 2014 at 1:22
Attachments:
We use ganymed in production in a highly loaded circumstances, and sometimes it
deadlocks when single java application executes multiple ssh connections in
separate threads.
Possible solution can be to rewrite parts of ganymed code to avoid syncronized
methods and use Lock objects instead, this will give us opportunity to close
connection with timeout even in case of lock.
We can provide patch. Will be glad to hear another cases/solutions of the same
problem (deadlocks).
Original issue reported on code.google.com by [email protected]
on 17 Aug 2012 at 7:36
What steps will reproduce the problem?
The following code will reproduce this error everytime:
public static void main(String[] args) throws IOException {
String hostname = "some-host";
String username = "username";
String password = "password";
Connection c = null;
SFTPv3Client client = null;
try {
c = new Connection(hostname);
c.connect();
c.authenticateWithPassword(username, password);
client = new SFTPv3Client(c);
SFTPv3FileHandle handle = client.createFile("test_basic.txt");
byte[] arr = new byte[262120];
client.write(handle, 0, arr, 0, arr.length);
}
finally {
c.close();
client.close();
}
}
This will fail for byte array size >= 262120 every time. It works for size <=
262119.
What is the expected output? What do you see instead?
I expect no output, and the file test_basic.txt with file size 262120 bytes to
appear in username's host directory on host somehost. Instead, I see the output:
Exception in thread "main" ch.ethz.ssh2.channel.ChannelClosedException: SSH
channel is closed. (Close requested by remote)
at ch.ethz.ssh2.channel.ChannelManager.sendData(ChannelManager.java:426)
at ch.ethz.ssh2.channel.ChannelOutputStream.write(ChannelOutputStream.java:71)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
at ch.ethz.ssh2.SFTPv3Client.sendMessage(SFTPv3Client.java:225)
at ch.ethz.ssh2.SFTPv3Client.sendMessage(SFTPv3Client.java:231)
at ch.ethz.ssh2.SFTPv3Client.write(SFTPv3Client.java:1507)
at ch.ethz.ssh2.SFTPv3Client.main(SFTPv3Client.java:1637)
And the file test_basic.txt with file size 0 bytes.
What version of the product are you using? On what operating system?
Version 261. I reproduced this on Ubuntu 13.04 and Windows 7.
It succeeds on version 251beta1 (for size 262120 and much larger too).
Please provide any additional information below.
262120 is remarkably close to 1024 * 256 = 262144...
Original issue reported on code.google.com by [email protected]
on 16 Oct 2013 at 6:47
I want to Create given file on server with given contents.
why following put() method is not present anymore in this 261 version?
SCPClient scp = ssh.createSCPClient();
scp.put(byte[] data, remoteFileName, remoteTargetDirectory)
Original issue reported on code.google.com by [email protected]
on 23 Jan 2014 at 11:58
Exception thrown when closing open file handle.
What steps will reproduce the problem?
1. Create client.
2. Perform file transfer using filehandler.
3. client.closeFile(fh)
(4. client.close())
Backtrace:
java.io.IOException: The server sent an invalid id field.
at ch.ethz.ssh2.SFTPv3Client.expectStatusOKMessage(SFTPv3Client.java:550)
at ch.ethz.ssh2.SFTPv3Client.closeHandle(SFTPv3Client.java:299)
at ch.ethz.ssh2.SFTPv3Client.closeFile(SFTPv3Client.java:1569)
Original issue reported on code.google.com by [email protected]
on 21 Jun 2011 at 1:28
What steps will reproduce the problem?
1. set up an unencrypted public key for a user (ssh-keygen -q -t rsa -N '' -f
~/.ssh/id_rsa)
2. Verify that you can log in using ssh to the remote host with just the
username of the user set up in step 1 (no pass-phrase should be prompted): ssh
-l user somehost
3. Try to connect using gnaymed in some java code.
com.trilead.ssh2.Connection conn = null;
conn = new com.trilead.ssh2.Connection("somehost");
conn.connect();
boolean isAuthenticated = conn.authenticateWithNone("aqua");
if (isAuthenticated == false) {
System.out.println("Authentication failed.");
} else {
System.out.println("Authentication succeeded.");
}
What is the expected output? What do you see instead?
Expect Authenticated succeeded but get Authenticated failed followed by
IllegalStateException.
What version of the product are you using? On what operating system?
trilead-ssh2.jar on windows 7 and linux
Please provide any additional information below.
The user's password on the remote host is hidden due to security policy. One
can only su to that user after logging in as oneself or set up an unencrypted
public key for the user which is allowed. What API do I use that will allow me
to specify only the userid where the software recognizes that there is no need
for a password or pass-phrase because the public key is not encrypted?
Original issue reported on code.google.com by [email protected]
on 10 Feb 2014 at 5:49
Ganymed release: 2.6.2
This issue is not a bug, but rather an improvement to consider.
In Sun_SSH server version 1.0.1 it appears that closing a Session obtained from
Connection.openSession() can cause the entire connection to go down. Trying to
re-use the Connection object will cause a failure. Therefore we would like to
handle the Session.close() function a bit differently.
It would be nice to subclass the Session object, and then perform extra
functionality for the close() function if such a server version is encountered.
Unfortunately the ability to do this isn't possible because the
Connection.openSession() uses internal private members (namely the
ChannelManager) to construct a Session object, so subclassing the Connection
object is not helpful.
Connection.java
----
public synchronized Session openSession() throws IOException {
this.checkConnection();
return new Session(cm, getOrCreateSecureRND());
}
----
Therefore, would it be possible to have the Connection object use a
SessionFactory instead that can be set on the Connection object to create
Session instances when openSession() is called?
This would be general enough to allow various tweaks to be done to the Session
objects, through subclassing, that are returned from Connection.openSession().
Attached is a proposed implementation to allow this functionality.
Original issue reported on code.google.com by [email protected]
on 29 Jul 2014 at 9:09
Attachments:
Using build260.
Calling connect() method on Connection, produces the following noisy output:
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: kex_algo=diffie-hellman-group14-sha1
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: server_host_key_algo=ssh-dss
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: enc_algo_client_to_server=aes128-ctr
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: enc_algo_server_to_client=aes128-ctr
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: mac_algo_client_to_server=hmac-sha1-96
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: mac_algo_server_to_client=hmac-sha1-96
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: comp_algo_client_to_server=none
Feb 14, 2013 7:12:32 PM ch.ethz.ssh2.log.Logger info
INFO: comp_algo_server_to_client=none
Similarly calling close() on the connection produces:
WARNING: Receive thread: error in receiveLoop: Socket closed
Original issue reported on code.google.com by [email protected]
on 15 Feb 2013 at 2:17
Ganymed release: 2.6.2
Client platform: Java 7
What steps will reproduce the problem?
The ganymed ssh library version 2.6.2 is used as part of our product for
establishing SSH connections. While testing, sometimes the following exception
occurred when the library was used for file transfer:
---
java.io.IOException: Remote scp sent illegal error code.
at ch.ethz.ssh2.SCPClient.readResponse(SCPClient.java:89)
at ch.ethz.ssh2.SCPOutputStream.<init>(SCPOutputStream.java:32)
at ch.ethz.ssh2.SCPClient.put(SCPClient.java:203)
---
This reason for the exception boiled down to a problem with the credential
used. However, the exception did produce a side effect of the session remaining
open.
Explanation:
Within the SCPClient.put() function, a Session was created to be passed to the
SCPOutputStream. The only time this Session would ever subsequently get closed
is when SCPOutputStream.close() was called. However since the SCPOutputStream's
constructor threw an IOException the created Session is never closed.
Here is the problematic code:
---
public SCPOutputStream put(final String remoteFile, long length, String
remoteTargetDirectory, String mode) throws IOException {
...
sess = conn.openSession();
sess.execCommand(cmd, charsetName);
return new SCPOutputStream(this, sess, remoteFile, length, mode);
}
---
Repeated execution attempts and IOExceptions caused many Session instances to
remain open and never get closed. The same problem can occur for the
SCPClient.get() call.
Attached is a proposed patch for the SCPClient, which ensures that sessions are
closed if there is a problem either executing the scp command or creating the
SCP IO stream.
Original issue reported on code.google.com by [email protected]
on 29 Jul 2014 at 8:43
Attachments:
String.getBytes(Charset) is not available in Java SE5:
return data.getBytes(Charset.forname("UTF-8"));
You can use getBytes(String charName) instead.
Additionally, String(byte[], int, int, Charset) in GetString() is unavailable
in SE5 too.
Same here, try String(byte[], int, int, String);
These are available in both Java SE5 and Java SE6.
Original issue reported on code.google.com by [email protected]
on 21 Jun 2011 at 1:00
The problem can be seen here:
if (payload_length >= len)
throw new IOException("Receive buffer too small (" + len + ", need " + payload_length + ")");
cis.read(buffer, off, payload_length);
http://code.google.com/p/ganymed-ssh-2/source/browse/trunk/src/main/java/ch/ethz
/ssh2/transport/TransportConnection.java#253
The `buffer` length check is done against `len`, but then writing is done in
`cis.read` starting at offset `off`. If `off+payload_length` is greater than
`len`, then there will be an attempt to write beyond the end of `buffer`.
The fix is to change the check to:
if ((off + payload_length) >= len)
(One way I could be wrong, that I'm not 100% sure of: If there's some guarantee
that `len` is "buffer size minus offset". But I don't see that that's the case.)
Original issue reported on code.google.com by [email protected]
on 10 Apr 2013 at 5:43
What steps will reproduce the problem?
1. Try to connect to SunOS 5.9 stock sftp server
2. Get exceptions
SSH Server version:
Ganymed release: SVN head (161)
Client platform: Centos 7
I have attached a patch that lets Ganymed connect to said SunOS 5.9 sftp server.
There are actually two different issues here:
1. The SunOS 5.9 ssh server tries to negotiate languages during connection, but
ganymed has an fixed internal empty list, so ssh negotiation fails. I added the
language string "C" to the fixed settings. I hope this will not cause problems
with other implementations.
A better alternative may be to simply drop the meaningless language negotiation
logic.
2. Ganymed only supports sftp protocol v3 and v6. I added the possibility to
downgrade the v3 connection attempts to a lower version, and added code to
disable (actually, throw an exception if called) the missing operations.
I admit that this is not a very elegant solution, but it works, does not
pollute the API, and does not require changes in existing code.
When connecting to sftp servers supporting protocol v3 everything works as it
did, when connecting to pre-v3 servers, some operations will not work. This can
be handled simply by relying on the exceptions thrown, or the code can check
for the negotiated protocol version, and avoid using the operations entirely.
Original issue reported on code.google.com by [email protected]
on 13 Aug 2014 at 11:53
Attachments:
Hi,
Sorry if I am opening this issue here but I didn't find any other way to ask my
question.
I'm looking for a SOCKS server with HTTP proxy support written in Java. The
only project I've found is JSocks which is a SOCKS server and supports chaining
to another SOCKS server but it doesn't support HTTP proxy.
Today I found this project and surprisingly I discovered that parts of codes
are exactly the same in JSocks. I don't know which one has used another but I
found out this project supports connecting to SSH server through HTTP proxy by
issuing CONNECT method. I think I can use the same trick to convert SSL
requests and ask proxy server to connect to HTTPS server. Correct me if I'm
mistaken. So what about other http methods(e.g. GET, POST, ...)?
Do you know any other related projects or codes to help me this way?
Any help would be appreciated.
Original issue reported on code.google.com by [email protected]
on 20 Jul 2014 at 7:43
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.