Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@LCamel
Last active June 5, 2020 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LCamel/5cb6a27dc4bd56080141227f088cb9ed to your computer and use it in GitHub Desktop.
Save LCamel/5cb6a27dc4bd56080141227f088cb9ed to your computer and use it in GitHub Desktop.
sftp / jsch
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import java.util.Vector;
class JSCHLogger implements com.jcraft.jsch.Logger {
public JSCHLogger() {
}
@Override
public boolean isEnabled(int pLevel) {
return true; // here, all levels enabled
}
@Override
public void log(int pLevel, String pMessage) {
System.out.println("log: " + pMessage);
}
}
public class AAA {
public static void main(String[] args) throws Exception {
JSch.setLogger(new JSCHLogger());
JSch jsch = new JSch();
Session sshSession1;
if (false) {
sshSession1 = jsch.getSession("walmart",
"69.26.104.103",
22);
} else {
sshSession1 = jsch.getSession("walmart-grocery",
"sftp.ec-horizontal-rewards.aws.oath.cloud",
22);
}
// sshSession1.setClientVersion("SSH-1.5");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
config.put("PubkeyAuthentication", "no");
config.put("PasswordAuthentication", "yes");
sshSession1.setConfig(config);
sshSession1.setPassword("xxxxxxxxxxxxxxxxxxxxxx");
sshSession1.connect();
ChannelSftp channel = (ChannelSftp) sshSession1.openChannel("sftp");
channel.connect();
Vector ls = channel.ls("/");
//System.out.println(ls);
for (int i = 0; i < ls.size(); i++) {
System.out.println(ls.get(i));
}
channel.disconnect();
sshSession1.disconnect();
System.out.println("done");
}
}
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=50725:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Users/lcamel/vc/lcamel-cms-test/target/classes:/Users/lcamel/.m2/repository/com/jcraft/jsch/0.1.55/jsch-0.1.55.jar:/Users/lcamel/.m2/repository/yahoo/yinst/cloud_messaging_client_java/cloud-messaging-client-java/2.4.6.7/cloud-messaging-client-java-2.4.6.7.jar:/Users/lcamel/.m2/repository/yahoo/yinst/yjava_ysecure/yjava_ysecure/1.47.7/yjava_ysecure-1.47.7.jar:/Users/lcamel/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.jar:/Users/lcamel/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.jar:/Users/lcamel/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.jar:/Users/lcamel/.m2/repository/org/glassfish/jersey/core/jersey-server/2.27/jersey-server-2.27.jar:/Users/lcamel/.m2/repository/org/glassfish/jersey/core/jersey-common/2.27/jersey-common-2.27.jar:/Users/lcamel/.m2/repository/org/glassfish/hk2/osgi-resource-locator/1.0.1/osgi-resource-locator-1.0.1.jar:/Users/lcamel/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.1/javax.ws.rs-api-2.1.jar:/Users/lcamel/.m2/repository/org/glassfish/jersey/media/jersey-media-jaxb/2.27/jersey-media-jaxb-2.27.jar:/Users/lcamel/.m2/repository/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar:/Users/lcamel/.m2/repository/org/glassfish/hk2/external/javax.inject/2.5.0-b42/javax.inject-2.5.0-b42.jar:/Users/lcamel/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/lcamel/.m2/repository/org/glassfish/jersey/core/jersey-client/2.27/jersey-client-2.27.jar:/Users/lcamel/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/lcamel/.m2/repository/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar com.yahoo.cloud.messaging.client.tutorial.AAA
objc[48913]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (0x108d414c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x108dbb4e0). One of the two will be used. Which one is undefined.
log: Connecting to sftp.ec-horizontal-rewards.aws.oath.cloud port 22
log: Connection established
log: Remote version string: SSH-2.0-AWS_SFTP_1.0
log: Local version string: SSH-2.0-JSCH-0.1.54
log: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
log: CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
log: CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
log: SSH_MSG_KEXINIT sent
log: SSH_MSG_KEXINIT received
log: kex: server: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
log: kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256
log: kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
log: kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
log: kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
log: kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
log: kex: server: none,zlib@openssh.com
log: kex: server: none,zlib@openssh.com
log: kex: server:
log: kex: server:
log: kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
log: kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
log: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
log: kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc
log: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
log: kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
log: kex: client: none
log: kex: client: none
log: kex: client:
log: kex: client:
log: kex: server->client aes128-ctr hmac-sha1 none
log: kex: client->server aes128-ctr hmac-sha1 none
log: SSH_MSG_KEX_ECDH_INIT sent
log: expecting SSH_MSG_KEX_ECDH_REPLY
log: ssh_rsa_verify: signature true
log: Permanently added 'sftp.ec-horizontal-rewards.aws.oath.cloud' (RSA) to the list of known hosts.
log: SSH_MSG_NEWKEYS sent
log: SSH_MSG_NEWKEYS received
log: SSH_MSG_SERVICE_REQUEST sent
log: SSH_MSG_SERVICE_ACCEPT received
log: Authentications that can continue: publickey,keyboard-interactive,password
log: Next authentication method: publickey
log: Authentications that can continue: password
log: Next authentication method: password
log: Authentication succeeded (password).
-rwxr--r-- 1 - - 0 Apr 10 15:14 walmart.empty.1.txt
drwxr--r-- 1 - - 0 Apr 24 05:48 processed
drwxr--r-- 1 - - 0 Apr 14 23:42 access_details
log: Disconnecting from sftp.ec-horizontal-rewards.aws.oath.cloud port 22
done
log: Caught an exception, leaving main loop due to Socket closed
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment