9
9
This program enables you to connect to sshd server and get the shell prompt.
10
$ CLASSPATH=.:../src javac Shell.java
11
$ CLASSPATH=.:../src java Shell
10
$ CLASSPATH=.:../build javac Shell.java
11
$ CLASSPATH=.:../build java Shell
12
12
You will be asked username, hostname and passwd.
13
13
If everything works fine, you will get the shell prompt. Output will
14
14
be ugly because of lacks of terminal-emulation, but you can issue commands.
16
16
- X11Forwarding.java
17
17
This program will demonstrate X11 forwarding.
18
$ CLASSPATH=.:../src javac X11Forwarding.java
19
$ CLASSPATH=.:../src java X11Forwarding
18
$ CLASSPATH=.:../build javac X11Forwarding.java
19
$ CLASSPATH=.:../build java X11Forwarding
20
20
You will be asked username, hostname, displayname and passwd.
21
21
If your X server does not run at 127.0.0.1, please enter correct
22
22
displayname. If everything works fine, you will get the shell prompt.
26
26
This program will demonstrate remote exec.
27
$ CLASSPATH=.:../src javac Exec.java
28
$ CLASSPATH=.:../src java Exec
27
$ CLASSPATH=.:../build javac Exec.java
28
$ CLASSPATH=.:../build java Exec
29
29
You will be asked username, hostname, displayname, passwd and command.
30
30
If everything works fine, given command will be invoked
31
31
on the remote side and outputs will be printed out. In this sample,
35
35
This program will demonstrate the ssh session via HTTP proxy.
36
$ CLASSPATH=.:../src javac ViaHTTP.java
37
$ CLASSPATH=.:../src java ViaHTTP
36
$ CLASSPATH=.:../build javac ViaHTTP.java
37
$ CLASSPATH=.:../build java ViaHTTP
38
38
You will be asked username, hostname, proxy-server and passwd.
39
39
If everything works fine, you will get the shell prompt.
42
42
This program will demonstrate the port forwarding like option -R of
43
43
ssh command; the given port on the remote host will be forwarded to
44
44
the given host and port on the local side.
45
$ CLASSPATH=.:../src javac PortForwardingR.java
46
$ CLASSPATH=.:../src java PortForwardingR
45
$ CLASSPATH=.:../build javac PortForwardingR.java
46
$ CLASSPATH=.:../build java PortForwardingR
47
47
You will be asked username, hostname, port:host:hostport and passwd.
48
48
If everything works fine, you will get the shell prompt.
49
49
Try the port on remote host.
52
52
This program will demonstrate the port forwarding like option -L of
53
53
ssh command; the given port on the local host will be forwarded to
54
54
the given remote host and port on the remote side.
55
$ CLASSPATH=.:../src javac PortForwardingL.java
56
$ CLASSPATH=.:../src java PortForwardingL
55
$ CLASSPATH=.:../build javac PortForwardingL.java
56
$ CLASSPATH=.:../build java PortForwardingL
57
57
You will be asked username, hostname, port:host:hostport and passwd.
58
58
If everything works fine, you will get the shell prompt.
59
59
Try the port on localhost.
63
63
I/O streams will be forwared to the given remote host and port on
64
64
the remote side. It is simmilar to the -L option of ssh command,
65
65
but you don't have to assign and open a local tcp port.
66
$ CLASSPATH=.:../src javac StreamForwarding.java
67
$ CLASSPATH=.:../src java StreamForwarding
66
$ CLASSPATH=.:../build javac StreamForwarding.java
67
$ CLASSPATH=.:../build java StreamForwarding
68
68
You will be asked username, hostname, host:hostport and passwd.
69
69
If everything works fine, System.in and System.out streams will be
70
70
forwared to remote port and you can send messages from command line.
72
72
- UserAuthPubKey.java
73
73
This program will demonstrate the user authentification by public key.
74
$ CLASSPATH=.:../src javac UserAuthPubKey.java
75
$ CLASSPATH=.:../src java UserAuthPubKey
74
$ CLASSPATH=.:../build javac UserAuthPubKey.java
75
$ CLASSPATH=.:../build java UserAuthPubKey
76
76
You will be asked username, hostname, privatekey(id_dsa) and passphrase.
77
77
If everything works fine, you will get the shell prompt
80
80
This program will demonstrate the packet compression.
81
$ CLASSPATH=.:../src javac Compression.java
82
$ CLASSPATH=.:../src java Compression
81
$ CLASSPATH=.:../build javac Compression.java
82
$ CLASSPATH=.:../build java Compression
83
83
You will be asked username, hostname and passwd.
84
84
If everything works fine, you will get the shell prompt.
85
85
In this program, all data from sshd server to jsch will be
89
89
This program will demonstrate the file transfer from local to remote.
90
$ CLASSPATH=.:../src javac ScpTo.java
91
$ CLASSPATH=.:../src java ScpTo file1 user@remotehost:file2
90
$ CLASSPATH=.:../build javac ScpTo.java
91
$ CLASSPATH=.:../build java ScpTo file1 user@remotehost:file2
92
92
You will be asked passwd.
93
93
If everything works fine, a local file 'file1' will copied to
94
94
'file2' on 'remotehost'.
97
97
This program will demonstrate the file transfer from remote to local
98
$ CLASSPATH=.:../src javac ScpFrom.java
99
$ CLASSPATH=.:../src java ScpFrom user@remotehost:file1 file2
98
$ CLASSPATH=.:../build javac ScpFrom.java
99
$ CLASSPATH=.:../build java ScpFrom user@remotehost:file1 file2
100
100
You will be asked passwd.
101
101
If everything works fine, a file 'file1' on 'remotehost' will copied to
105
105
This program will demonstrate the sftp protocol support.
106
$ CLASSPATH=.:../src javac Sftp.java
107
$ CLASSPATH=.:../src java Sftp
106
$ CLASSPATH=.:../build javac Sftp.java
107
$ CLASSPATH=.:../build java Sftp
108
108
You will be asked username, host and passwd.
109
109
If everything works fine, you will get a prompt 'sftp>'.
110
110
'help' command will show available command.
114
114
- KnownHosts.java
115
115
This program will demonstrate the 'known_hosts' file handling.
116
$ CLASSPATH=.:../src javac KnownHosts.java
117
$ CLASSPATH=.:../src java KnownHosts
116
$ CLASSPATH=.:../build javac KnownHosts.java
117
$ CLASSPATH=.:../build java KnownHosts
118
118
You will be asked username, hostname, a path for 'known_hosts' and passwd.
119
119
If everything works fine, you will get the shell prompt.
120
120
In current implementation, jsch only reads 'known_hosts' for checking
123
123
- UserAuthKI.java
124
124
This program will demonstrate the keyboard-interactive authentication.
125
$ CLASSPATH=.:../src javac UserAuthKI.java
126
$ CLASSPATH=.:../src java UserAuthKI
125
$ CLASSPATH=.:../build javac UserAuthKI.java
126
$ CLASSPATH=.:../build java UserAuthKI
127
127
If the remote sshd supports keyboard-interactive authentication,
128
128
you will be prompted.
131
131
This progam will demonstrate the DSA keypair generation.
132
$ CLASSPATH=.:../src javac KeyGen.java
133
$ CLASSPATH=.:../src java KeyGen rsa output_keyfile comment
132
$ CLASSPATH=.:../build javac KeyGen.java
133
$ CLASSPATH=.:../build java KeyGen rsa output_keyfile comment
135
$ CLASSPATH=.:../src java KeyGen dsa output_keyfile comment
135
$ CLASSPATH=.:../build java KeyGen dsa output_keyfile comment
136
136
You will be asked a passphrase for output_keyfile.
137
137
If everything works fine, you will get the DSA or RSA keypair,
138
138
output_keyfile and output_keyfile+".pub".
141
141
- ChangePassphrase.java
142
142
This program will demonstrate to change the passphrase for a
143
143
private key file instead of creating a new private key.
144
$ CLASSPATH=.:../src javac ChangePassphrase.java
145
$ CLASSPATH=.:../src java ChangePassphrase private-key
144
$ CLASSPATH=.:../build javac ChangePassphrase.java
145
$ CLASSPATH=.:../build java ChangePassphrase private-key
146
146
A passphrase will be prompted if the given private-key has been
147
147
encrypted. After successfully loading the content of the
148
148
private-key, the new passphrase will be prompted and the given
149
149
private-key will be re-encrypted with that new passphrase.
152
This program will demonstrate how to use "aes128-cbc".
155
This program will demonstrate how to provide a network service like
156
inetd by using remote port-forwarding functionality.