Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JSch jsch = new JSch();
- jsch.setLogger(new MyLogger());
- System.setProperty("java.security.krb5.conf", "/Users/swithana/git/KerberosConnector/src/main/resources/krb5.conf");
- System.setProperty("java.security.auth.login.config", "/Users/swithana/git/KerberosConnector/src/main/resources/mylogin.conf");
- System.setProperty("javax.security.auth.useSubjectCredsOnly", "true");
- try {
- jsch.addIdentity(privateKey,paraphrase);
- jsch.setKnownHosts("/Users/swithana/.ssh/known_hosts");
- Session session = jsch.getSession(user, host, 22);
- Properties config = new java.util.Properties();
- config.put("StrictHostKeyChecking", "no");
- config.put("PreferredAuthentications",
- "gssapi-with-mic,publickey,password,keyboard-interactive");
- session.setConfig(config);
- session.connect(20000);
- Channel channel = session.openChannel("exec");
- ((ChannelExec) channel).setCommand( command);
- channel.setInputStream(null);
- ((ChannelExec) channel).setErrStream(System.err);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement