HI Lother,

Here is the code where we creating the session.

public Session getSession(String remoteUser) throws Exception{

        LoginConfigUtil loginConfigUtil = new LoginConfigUtil();
        String ticketCache = loginConfigUtil.searchTicket(remoteUser);
        javax.security.auth.login.Configuration.setConfiguration(new
JaaSConfiguration(ticketCache));

        JSch jsch = new JSch();
        JSch.setLogger(new MyLogger());

        Session session = null;
        try {
            session = jsch.getSession(remoteUser, host, 22);
            Properties config = new Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect(5000);
        } catch (JSchException e) {
            log.error("Authentication fails.." , e);
            throw new Exception("Authentication fails..", e);
        }
        return session;
    }

Each method will first get the session object using this method and then
create a SFTP channel.

Hope I provide you the code that you need.

Thanks,
Chathuri

On Mon, Sep 8, 2014 at 9:03 AM, Lothar Kimmeringer <j...@kimmeringer.de>
wrote:

> Am 08.09.2014 13:15, schrieb Chathuri Wimalasena:
> > This is the constructor of the commandExecuter.
> >
> > public CommandExecutor(String user) throws Exception{
> >         try {
> >             remoteUser = user;
> >             kerberosConnector = new KerberosConnector();
> >             commandCentral = new CommandCentral();
> >             stringUtils = new StringUtils();
> >             resultItemList = new ArrayList<Item>();
> >             pwd();
> >         } catch (Exception e) {
> >             log.error("Error occured..", e);
> >             throw new Exception("Error occured", e);
> >         }
> >
> >     }
>
> where does the connection and authentication to the server
> take place?
>
> > public KerberosConnector() throws Exception{
> [...]
> > }
>
> I'm not sure what Kerberos has to do with SSH and still I don't
> see any code where you actually use JSCH. Without that how
> is anybody supposed to be able to say anything about what
> might go wrong?
>
>
> Cheers, Lothar
>
>
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> JSch-users mailing list
> JSch-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jsch-users
>
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to