Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection.java:
- try {
- /*
- * we will use keyboard authentication method
- */
- JSch jsch=new JSch();
- Session session = jsch.getSession(msUserName, msHostName, miPort);
- /*
- * set authentication object to session
- */
- UserInfo ui = new MyUserInfo(msUserName, msPassword);
- session.setUserInfo(ui);
- /*
- * throw an exception if connection can not be established in 10 seconds
- */
- session.setTimeout(10000);
- /*
- * connect to node
- */
- session.connect();
- /*
- * open sftp channel for file transfer
- */
- sftpChannel =(ChannelSftp)session.openChannel("sftp");
- sftpChannel.connect();
- return true;
- } catch (JSchException e) {
- return false;
- } catch (Exception e) {
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement