Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#8 jsch does not work on non-ASCII platforms

Andrew Armstrong

I tried running jsch on IBM's OS/390 operating system
but it doesn't work because OS/390 (and z/OS) is an
EBCDIC platform and jsch is assuming it is running on
an ASCII platform. For example, an Ethereal trace shows
the SSH handshake from OS/390 to the sshd server going
on the wire as 'SSH-2.0-JSCH-0.1.16' encoded in EBCDIC,
which is ignored by the sshd server and eventually the
connection times out.

It *should* work, however, and I think it would be
fairly easy to do - compared to the work you've already
put into the project. Code from other projects such as
Apache XALAN works just fine on OS/390 and z/OS.

I've only had a brief look at the jsch code, but it
appears that in the SSH protocol data stream, there is
mixed ASCII text and binary data 'on the wire' to/from
the sshd server. What I think needs to be done is to
treat on-wire ASCII data as text...not as an array of
bytes. Binary data can still be treated as byte arrays.
When reading textual data from the wire, the bytes can
be stored in a String (which will be encoded in the
platform's default character set). Conversely, when
writing textual data to the wire from a String, the
String can be converted to an ASCII byte array (if the
platform is not an ASCII platform) before appending it
to the output buffer.

Reading ASCII textual data from the wire could be done
(in the Buffer class, say) by something like:

public String getText()
int i = getInt();
byte[] foo = new byte[i];
getByte(foo, 0, i);
return new String(foo);

To write textual data to the wire encoded in ASCII, you
would need something like:

public void putText(String s)
putByte(s.getBytes("US-ASCII"), 0, s.length());
catch (UnsupportedEncodingException e)
{ //...or just throw this exception
putByte(s.getBytes(), 0, s.length());
e.printStackTrace(); // ...possibly unpleasant