Hi Sachith
Difficult to say what's wrong with no output.
This should be helpful to you though. Here is a rough looking working (just
executed) example based on Shell.java along with the jaas login config file.
Shell2.java
============
import com.jcraft.jsch.*;
public class Shell2 {
public static void main(String[] args) {
try{
JSch jsch=new JSch();
String user="quixote";
String host="rocinante";
Session session=jsch.getSession(user, host, 22);
java.util.Hashtable config=new java.util.Hashtable();
config.put("StrictHostKeyChecking", "no");
config.put("PreferredAuthentications", "gssapi-with-mic");
session.setConfig(config) ;
session.connect(30000); // making a connection with timeout.
Channel channel=session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect(3*1000);
}
catch(Exception e) {
System.out.println(e);
}
}
}
logintc.conf
============
/**
* Login Configuration for JAAS.
*/
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
debug="true"
useTicketCache="true"
ticketCache="/tmp/krb5cc_25201_FnWyyW4447";
};
sancho@darkstar:-/jsch> kinit
Password for [email protected]:
sancho@darkstar:-/jsch> klist
Ticket cache: FILE:/tmp/krb5cc_25201_FnWyyW4447
Default principal: [email protected]
Valid starting Expires Service principal
02/21/14 11:43:47 02/21/14 23:43:47 krbtgt/[email protected]
renew until 02/28/14 11:43:43
sancho@darkstar:-/jsch> ~/java/bin/java -version
java version "1.6.0_13"
Java (TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
sancho@darkstar:-/jsch> ~/java/bin/java -classpath jsch-0.1.49.jar:.
-Djava.security.krb5.conf=/etc/krb5.conf
-Djava.security.auth.login.config=logintc.conf
-Djavax.security.auth.useSubjectCredsOnly=false Shell2
Debug is true storeKey false useTicketCache true useKeyTab false
doNotPrompt false ticketCache is /tmp/krb5cc_25201_FnWyyW4447 iSlnitiator
true KeyTab is null refreshKrb5Config is false principal is null
tryFirstPass is false useFirstPass is false storePass is false clearPass is
false
Acquire TGT from Cache
Principal is [email protected]
Commit Succeeded
Last login: Fri Feb 21 11:41:38 2014 from darkstar
rocinante quixote/quixote> cat .k5login
[email protected]
rocinante quixote/quixote> exit
exit
logout
Here is a working example for a login config file for use with a keytab if
you want to try that.
loginkeytab.conf
================
/**
* Login Configuration for JAAS.
*/
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
useKeyTab="true"
keyTab="/home/sancho/jsch/sancho.keytab"
storeKey="true"
principal="sancho";
};
Borislav
On Fri, Feb 21, 2014 at 11:12 AM, Sachith Withana <[email protected]>wrote:
> Thank you all for the quick reply.
> I still can't get this working.
> Here's the login file:
>
> com.sun.security.jgss.krb5.initiate {
> com.sun.security.auth.module.Krb5LoginModule required
> debug="true"
> doNotPrompt="true"
> useTicketCache="true"
> ticketCache="/Users/swithana/krb5cc_swithana"
> };
>
> my full class : http://pastebin.com/b5jnAuYZ
>
> thanks again for the help!
>
>
> On Fri, Feb 21, 2014 at 2:06 AM, Atsuhiko Yamanaka <[email protected]>wrote:
>
>> Hi,
>>
>> Mr. Borislav Stoichkov had kindly replied to the that message,
>> but it seems that the mailing-list system at sf.net has rejected it.
>> # I don't know the reason for it, unfortunately.
>> Anyway, please allow me to post it here on behalf of him,
>>
>> > From: Borislav Stoichkov <[email protected]>
>> > To: Sachith Withana <[email protected]>
>> > Cc: "[email protected]" <
>> [email protected]>
>> > Date: Fri, 21 Feb 2014 00:01:33 -0500
>> > Subject: Re: [JSch-users] Kerberos Jsch Help
>> >
>> > Hello Sachith
>> >
>> > The login.conf configuration file contains the GSSAPI/Kerberos
>> parameters for the authentication. I assume you want to use an existing
>> ticket cache. If that is the case, the login.conf file might look something
>> like this
>> >
>> > com.sun.security.jgss.initiate {
>> > com.sun.security.auth.module.Krb5LoginModule required
>> > debug="false"
>> > doNotPrompt="true"
>> > useTicketCache="true"
>> > ticketCache="/path/to/krb5cc_username"
>> > };
>> >
>> > The configuration might be called com.sun.security.jgss.krb5.initiate
>> based on the version of java you have but if I recall correctly you would
>> get a clear error message about that. You can put it in debug mode too and
>> that should help to determine what is happening.
>> >
>> > Good luck!
>> > Borislav
>>
>>
>> Sincerely,
>> --
>> Atsuhiko Yamanaka
>> JCraft,Inc.
>> 1-14-20 HONCHO AOBA-KU,
>> SENDAI, MIYAGI 980-0014 Japan.
>> Tel +81-22-723-2150
>> Skype callto://jcraft/
>> Twitter: http://twitter.com/ymnk
>> Facebook: http://facebook.com/aymnk
>>
>
>
>
> --
> Thanks,
> Sachith Withana
>
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> _______________________________________________
> JSch-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jsch-users
>
>
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users