Hi All,
I am new to JSCH and would appreciate your help! I need to SFTP a file to
remote sshd server using JSCH. From the examples and online resources,
pasted below is the code I wrote for the purpose. I have excluded exception
handling etc. for readability. The code seems to work and transfers file to
our sftp server. I had couple of questions around the code.
--------------------------------------
Questions:
1. In all the examples that I came across online the line
"Security.addProvider(new com.sun.crypto.provider.SunJCE());" ... is
commented. If I uncomment this line the program doesnt compile even though
my JDK is in the classpath. I understand that JSCH uses JCE for encryption.
So, if we comment this line, does it use any default JCE encryption
mechanism ? or is my code not secure for sftp file tranfer after this line
is commented?
2. Is it okay to set "no" for "StrictHostKeyChecking" when transferring file
to remote server using JSCH? Or does it make the sftp file transfer
insecure?
3. Please go through my code below and let me know if I am missing anything
from security point of view or in general?
----------------------------------------
Code to transfer test file to remote sftp server:
JSch jsch = new JSch();
Session session = null;
Channel channel = null;
ChannelSftp c = null;
session = jsch.getSession("USER1", "myserver.abc.com");
session.setPassword("PASS1");
//Security.addProvider(new com.sun.crypto.provider.SunJCE());
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
channel = session.openChannel("sftp");
channel.connect();
c = (ChannelSftp)channel;
c.cd("/");
File f = new File("myfile.test");
FileInputStream fis = new FileInputStream(f);
c.put(fis, f.getName());
--------------------
Cheers,
Dale Anderson
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users