1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
README of example directory
====================================================================
Last modified: Wed Oct 16 13:53:12 UTC 2002
This directory contains some examples, which demonstrate how to use JSch
- Shell.java
This program enables you to connect to sshd server and get the shell prompt.
$ CLASSPATH=.:../build javac Shell.java
$ CLASSPATH=.:../build java Shell
You will be asked username, hostname and passwd.
If everything works fine, you will get the shell prompt. Output will
be ugly because of lacks of terminal-emulation, but you can issue commands.
- X11Forwarding.java
This program will demonstrate X11 forwarding.
$ CLASSPATH=.:../build javac X11Forwarding.java
$ CLASSPATH=.:../build java X11Forwarding
You will be asked username, hostname, displayname and passwd.
If your X server does not run at 127.0.0.1, please enter correct
displayname. If everything works fine, you will get the shell prompt.
Try X applications; for example, xlogo.
- Exec.java
This program will demonstrate remote exec.
$ CLASSPATH=.:../build javac Exec.java
$ CLASSPATH=.:../build java Exec
You will be asked username, hostname, displayname, passwd and command.
If everything works fine, given command will be invoked
on the remote side and outputs will be printed out.
- ViaHTTP.java
This program will demonstrate the ssh session via HTTP proxy.
$ CLASSPATH=.:../build javac ViaHTTP.java
$ CLASSPATH=.:../build java ViaHTTP
You will be asked username, hostname, proxy-server and passwd.
If everything works fine, you will get the shell prompt.
- ViaSOCKS.java
This program will demonstrate the ssh session via SOCKS proxy.
$ CLASSPATH=.:../build javac ViaSOCKS.java
$ CLASSPATH=.:../build java ViaSOCKS
You will be asked username, hostname, proxy-server and passwd.
If everything works fine, you will get the shell prompt.
- PortForwardingR.java
This program will demonstrate the 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.
$ CLASSPATH=.:../build javac PortForwardingR.java
$ CLASSPATH=.:../build java PortForwardingR
You will be asked username, hostname, port:host:hostport and passwd.
If everything works fine, you will get the shell prompt.
Try the port on remote host.
- PortForwardingL.java
This program will demonstrate the port forwarding like option -L of
ssh command; the given port on the local host will be forwarded to
the given remote host and port on the remote side.
$ CLASSPATH=.:../build javac PortForwardingL.java
$ CLASSPATH=.:../build java PortForwardingL
You will be asked username, hostname, port:host:hostport and passwd.
If everything works fine, you will get the shell prompt.
Try the port on localhost.
- StreamForwarding.java
This program will demonstrate the stream forwarding. The given Java
I/O streams will be forwared to the given remote host and port on
the remote side. It is simmilar to the -L option of ssh command,
but you don't have to assign and open a local tcp port.
$ CLASSPATH=.:../build javac StreamForwarding.java
$ CLASSPATH=.:../build java StreamForwarding
You will be asked username, hostname, host:hostport and passwd.
If everything works fine, System.in and System.out streams will be
forwared to remote port and you can send messages from command line.
- UserAuthPubKey.java
This program will demonstrate the user authentification by public key.
$ CLASSPATH=.:../build javac UserAuthPubKey.java
$ CLASSPATH=.:../build java UserAuthPubKey
You will be asked username, hostname, privatekey(id_dsa) and passphrase.
If everything works fine, you will get the shell prompt
- Compression.java
This program will demonstrate the packet compression.
$ CLASSPATH=.:../build javac Compression.java
$ CLASSPATH=.:../build java Compression
You will be asked username, hostname and passwd.
If everything works fine, you will get the shell prompt.
In this program, all data from sshd server to jsch will be
compressed.
- ScpTo.java
This program will demonstrate the file transfer from local to remote.
$ CLASSPATH=.:../build javac ScpTo.java
$ CLASSPATH=.:../build java ScpTo file1 user@remotehost:file2
You will be asked passwd.
If everything works fine, a local file 'file1' will copied to
'file2' on 'remotehost'.
- ScpFrom.java
This program will demonstrate the file transfer from remote to local
$ CLASSPATH=.:../build javac ScpFrom.java
$ CLASSPATH=.:../build java ScpFrom user@remotehost:file1 file2
You will be asked passwd.
If everything works fine, a file 'file1' on 'remotehost' will copied to
local 'file1'.
- Sftp.java
This program will demonstrate the sftp protocol support.
$ CLASSPATH=.:../build javac Sftp.java
$ CLASSPATH=.:../build java Sftp
You will be asked username, host and passwd.
If everything works fine, you will get a prompt 'sftp>'.
'help' command will show available command.
In current implementation, the destination path for 'get' and 'put'
commands must be a file, not a directory.
- KnownHosts.java
This program will demonstrate the 'known_hosts' file handling.
$ CLASSPATH=.:../build javac KnownHosts.java
$ CLASSPATH=.:../build java KnownHosts
You will be asked username, hostname, a path for 'known_hosts' and passwd.
If everything works fine, you will get the shell prompt.
In current implementation, jsch only reads 'known_hosts' for checking
and does not modify it.
- UserAuthKI.java
This program will demonstrate the keyboard-interactive authentication.
$ CLASSPATH=.:../build javac UserAuthKI.java
$ CLASSPATH=.:../build java UserAuthKI
If the remote sshd supports keyboard-interactive authentication,
you will be prompted.
- KeyGen.java
This progam will demonstrate the DSA keypair generation.
$ CLASSPATH=.:../build javac KeyGen.java
$ CLASSPATH=.:../build java KeyGen rsa output_keyfile comment
or
$ CLASSPATH=.:../build java KeyGen dsa output_keyfile comment
You will be asked a passphrase for output_keyfile.
If everything works fine, you will get the DSA or RSA keypair,
output_keyfile and output_keyfile+".pub".
The private key and public key are in the OpenSSH format.
- ChangePassphrase.java
This program will demonstrate to change the passphrase for a
private key file instead of creating a new private key.
$ CLASSPATH=.:../build javac ChangePassphrase.java
$ CLASSPATH=.:../build java ChangePassphrase private-key
A passphrase will be prompted if the given private-key has been
encrypted. After successfully loading the content of the
private-key, the new passphrase will be prompted and the given
private-key will be re-encrypted with that new passphrase.
- AES.java
This program will demonstrate how to use "aes128-cbc".
- Daemon.java
This program will demonstrate how to provide a network service like
inetd by using remote port-forwarding functionality.
- Logger.java
This program will demonstrate how to enable logging mechanism and
get logging messages.
- Subsystem.java
This program will demonstrate how to use the Subsystem channel.
- Sudo.java
This program will demonstrate how to exec 'sudo' on the remote.
- ScpToNoneCipher.java
This program will demonstrate how to enable none cipher.
- JumpHosts.java
This program will demonstrate SSH through jump hosts.
- OpenSSHConfig.java
This program will demonstrate how OpenSSH's config is supported.
|