Sachith Withana
2014-02-20 16:43:14 UTC
Hi all,
I need to get kerberos working through Java. ( SSH using the kerberos
ticket)
Currently it works with the terminal ( ssh host command) using the
gssapi-with-mic
But I'm having trouble getting it working with the JSCH library in Java.
Here's the code snippet I tried. ( pastebin: http://pastebin.com/sX8pUQSq)
Any suggestion is highly appreciated ..!!
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);
I need to get kerberos working through Java. ( SSH using the kerberos
ticket)
Currently it works with the terminal ( ssh host command) using the
gssapi-with-mic
But I'm having trouble getting it working with the JSCH library in Java.
Here's the code snippet I tried. ( pastebin: http://pastebin.com/sX8pUQSq)
Any suggestion is highly appreciated ..!!
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);
--
Thanks,
Sachith Withana
Thanks,
Sachith Withana