import com.jcraft.jsch.*;
public class CPISFTPTest {
private static final String USERNAME = "myusername";
private static final String PASSWORD = "mypassword";
private static final String HOST = "127.0.0.1";
private static final int PORT = 22;
public static void main(String[] args) {
JSch jsch = new JSch();
Session jschSession = null;
System.out.printf("Compiled with jsch version %s%n", jsch.VERSION);
try {
jsch.setKnownHosts("known_hosts");
jschSession = jsch.getSession(USERNAME, HOST, PORT);
jschSession.setPassword(PASSWORD);
jschSession.connect();
HostKey hostKey = jschSession.getHostKey();
System.out.printf("Connected to %s, using key %s having fingerprint %s%n",
HOST, hostKey.getKey(), hostKey.getFingerPrint(jsch));
} catch (Exception exception) {
exception.printStackTrace();
} finally {
jschSession.disconnect();
}
}
}
javac -cp "jsch-0.2.8.jar" CPISFTPTest.java
java -cp ".:jsch-0.2.8.jar" CPISFTPTest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |