Skip to content

Commit

Permalink
jsch-0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed Oct 9, 2010
0 parents commit ba65142
Show file tree
Hide file tree
Showing 53 changed files with 4,689 additions and 0 deletions.
482 changes: 482 additions & 0 deletions COPYING

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ChangeLog of JSch
====================================================================
Last modified: Sun Oct 20 14:21:46 UTC 2002


Changes since version 0.0.1:
- the tunneling via HTTP proxy is supported.
- port forwarding like option -R of ssh command.
the given port on the remote host will be forwarded to the given host
and port on the local side.

Changes since version 0.0.2:
- remote exec is supported.
- examples/Exec.java is added.
- build.xml and some scripts for Ant are added. (lbruand)
- Const class is added. (lbruand)
126 changes: 126 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@

JSch

Java Secure Channel
by ymnk@jcraft.com, JCraft,Inc.

http://www.jcraft.com/jsch/

Last modified: Sun Oct 20 14:23:06 UTC 2002

Description
===========
JSch is a pure Java implementation of SSH2. JSch allows you to
connect to an sshd server and use port forwarding, X11 forwarding,
file transfer, etc., and you can integrate its functionality
into your own Java programs. JSch is licensed under GNU LGPL.


Documentation
=============
* README files all over the source tree have info related to the stuff
in the directories.
* ChangeLog: what changed from the previous version?


Directories & Files in the Source Tree
======================================
* src/com/ has source trees of JSch
* example/ has some samples, which demonstrate the usages.
* tools/ has scripts for Ant.

Why JSch?
==========
Our intension of developing this stuff is to enable users of our pure
java X servers, WiredX(http://wiredx.net/), WeirdX to enjoy secure X
sessions. So, our efforts have been done mostly in the SSH2 protocol related
to X Window System; X11 forwarding. Of course, we are also interested in
adding other functionalities; port forward, file transfer, terminal emulation, etc.


Features
========
* JSch requires J2SE 1.4.
JSch is in pure Java, but it depends on JavaTM Cryptography
Extension (JCE), which is included in J2SE 1.4.0 or later.
* SSH2 protocol support.
* Key exchange: diffie-hellman-group-exchange-sha1
From the implementation of Diffie-Hellman key exchange by JCE,
the bit-size of prime number p is 1024.
* Cipher: blowfish-cbc
* MAC: hmac-md5
* Key type: ssh-dss
* Userauth: password
* X11 forwarding.
* xauth spoofing.
* connection through HTTP proxy.
* port forwarding(-R).
* remote exec.
* JSch is licensed under GNU LGPL.


How To Try
==========
This archive does not include java byte code, so please compile
the source code by your self.
$ cd jsch-?.?.?/src
$ javac com/jcraft/jsch/*java com/jcraft/jsch/jce/*java
'/examples/' directory has included some samples to demonstrate what
JSch can do. Please refer to '/examples/README' file.


TODO
====
* Cipher: 3des-cbc
* MAC: hmac-sha1, hmac-sha1-96,
* hmac-md5-96
* Key type: ssh-rsa
* Userauth: publickey
* port forwarding(-L).
* file transfer.
* packet compression.
JZlib(http://www.jcraft.com/jzlib/) will be used.
* re-implementation with java.nio.
* replacing cipher, hash by JCE with pure Java code.
It seems BeeCrypt(http://www.virtualunlimited.com/products/beecrypt/),
which in under GNU LGPL, can be integrated into JSch.
* terminal emulation.
* error handling.


Copyrights & Disclaimers
========================
JSch is copyrighted by JCraft,Inc. and is licensed through the
GNU Library General Public License.
Read the COPYING file for the complete license.


Credits and Acknowledgments
============================
JSch has been developed by ymnk@jcaft.com and it can not be hacked
without several help.
* First of all, we want to thank JCE team</a> at Sun Microsystems.
For long time, we had planed to implement SSH2 in pure Java,
but we had hesitated to do because tons of work must be done for
implementing ciphers, hashes, etc., from the scratch.
Thanks to newly added functionalities to J2SE 1.4.0, we could
release the first working version within just 1.5 weeks from the scratch.
* We appreciate the OpenSSH project.
The options '-ddd' of sshd, '---vvv' of ssh and the compile options
'-DPACKET_DEBUG', '-DDEBUG_KEXDH' and '-DDEBUG_KEX' were very
useful in debugging JSch.
* We appreciate IETF sesch working group and SSH Communications Security Corp.
Without the standardization of the protocol, we could not get the
chance to implement JSch.
* We also appreciate Seigo Haruyama(http://www.unixuser.org/~haruyama/),
who are interpreting drafts of SSH2 protocol in Japanese.
His works were very useful for us to understand the technical terms
in our native language.


If you have any comments, suggestions and questions, write us
at jsch@jcraft.com


``SSH is a registered trademark and Secure Shell is a trademark of
SSH Communications Security Corp (www.ssh.com)''.
17 changes: 17 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off

echo.
echo JSch Build System
echo -----------------

set OLD_ANT_HOME=%ANT_HOME%
set ANT_HOME=tools

set OLD_CLASSPATH=%CLASSPATH%

%ANT_HOME%\bin\ant.bat -emacs %1 %2 %3 %4 %5 %6 %7 %8
goto cleanup

:cleanup
set ANT_HOME=%OLD_ANT_HOME%
set CLASSPATH=%OLD_CLASSPATH%
25 changes: 25 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

echo
echo "JSch Build System"
echo "-----------------"

export ANT_HOME=$ANT_HOME
ANT_HOME=./tools

export OLD_CLASSPATH=$CLASSPATH



export CLASSPATH

chmod u+x ${ANT_HOME}/bin/antRun
chmod u+x ${ANT_HOME}/bin/ant

export PROPOSAL=""


${ANT_HOME}/bin/ant -emacs $@

export CLASSPATH=$OLD_CLASSPATH
export ANT_HOME=$OLD_ANT_HOME
47 changes: 47 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<project name="Jsch" default="dist" basedir=".">
<description>
JSch is a pure Java implementation of SSH2. JSch allows you to connect to an
sshd server and use port forwarding, X11 forwarding, file transfer, etc., and
you can integrate its functionality into your own Java programs
</description>
<!-- set global properties for this build -->
<property name="version" location="0.0.2"/>
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<path id="project.cp">
<pathelement location="${build}"/>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="run" depends="compile">
<java classname="Login" classpathref="project.cp"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/jsch-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>


119 changes: 119 additions & 0 deletions examples/Exec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import com.jcraft.jsch.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Exec{
public static void main(String[] arg){

String xhost="127.0.0.1";
int xport=0;
Request request;

try{
JSch jsch=new JSch();
String host=JOptionPane.showInputDialog("Please enter hostname",
"localhost");

Session session=jsch.getSession(host, 22);

String display=JOptionPane.showInputDialog("Please enter display name",
xhost+":"+xport);
xhost=display.substring(0, display.indexOf(':'));
xport=Integer.parseInt(display.substring(display.indexOf(':')+1));

session.setX11Host(xhost);
session.setX11Port(xport+6000);

// username and password will be given via UserInfo interface.
UserInfo ui=new MyUserInfo();
session.setUserInfo(ui);

session.connect();

request=new RequestX11();
request.request(session, session.getChannel());

String command=JOptionPane.showInputDialog("Please enter command",
"set|grep SSH");
request=new RequestExec();
((RequestExec)request).setCommand(command);
request.request(session, session.getChannel());

session.start();
}
catch(Exception e){
System.out.println(e);
}
}
public static class MyUserInfo implements UserInfo{
public String getName(){
passwordDialog.show();
passwd=new String(passwordField.getPassword());
username=usernameField.getText();
passwordField.setText("");
if(passwd.length()==0)passwd=null;
return username;
}
public String getPassword(){
if(passwd==null){
passwordDialog.show();
passwd=new String(passwordField.getPassword());
username =usernameField.getText();
passwordField.setText("");
}
return passwd;
}

public boolean prompt(String str){
Object[] options={ "yes", "no" };
int foo=JOptionPane.showOptionDialog(null,
str,
"Warning",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
return foo==0;
}

public boolean retry(){
passwd=null;
passwordField.setText("");
return true;
}

String username;
String passwd;
final JDialog passwordDialog=new JDialog(new JFrame(), true);
JLabel mainLabel=new JLabel("Please enter your user name and password: ");
JLabel userLabel = new JLabel("User name: ");
JLabel passwordLabel = new JLabel("Password: ");
JTextField usernameField = new JTextField(20);
JPasswordField passwordField = new JPasswordField(20);
JButton okButton = new JButton("OK");

MyUserInfo(){
Container pane = passwordDialog.getContentPane();
pane.setLayout(new GridLayout(4, 1));
pane.add(mainLabel);
JPanel p2 = new JPanel();
p2.add(userLabel);
p2.add(usernameField);
usernameField.setText(username);
pane.add(p2);
JPanel p3 = new JPanel();
p3.add(passwordLabel);
p3.add(passwordField);
pane.add(p3);
JPanel p4 = new JPanel();
p4.add(okButton);
pane.add(p4);
passwordDialog.pack();
ActionListener al=new ActionListener(){
public void actionPerformed(ActionEvent e) { passwordDialog.hide(); }
};
okButton.addActionListener(al);
passwordField.addActionListener(al);
}
}
}
Loading

0 comments on commit ba65142

Please sign in to comment.