Hi Srikanth, you can create your known hosts file without jsch.
Jsch uses the known hosts file format of openssh. For openssh-server on linux the host keys reside in /etc/ssh/ssh_host_key.pub (DSA) and ssh_host_rsa_key.pub (RSA). You can take the contents, precede them by the host's id and store them in you known hosts file. See <http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&sektion=8> ( Search for SSH_KNOWN_HOSTS FILE FORMAT ). So a simple shell command line does the job: echo `uname -n` `cat /etc/ssh/ssh_host_rsa_key.pub` >> myKnownHosts If 'uname -n' returns the same name you use to connect, that is. HTH, Heiner srikanth k.m wrote: > > Hi John, > > Thanks for your response. > > > Is it that I need to use JSch library only to get the hostkey or can I > get it by means of any third party? . Is the hostkey format stored in > the keyfile specific to JSch or it is a standard? > > Thnaks > > On Thu, Sep 11, 2008 at 9:55 AM, Stote, John (RBC Dexia IS) > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > > Here is how I do it. > > Session session = jsch.getSession(username, address, port); > > UserInfo ui = new MyUserInfo(); > > session.setUserInfo(ui); > > session.connect(); > > HostKey hk=session.getHostKey(); > String tf = hk.getFingerPrint( jsch ); > > > ------------------------------------------------------------------------ > *From:* [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > [mailto:[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>] *On Behalf Of > *srikanth k.m > *Sent:* Thursday, 11 September 2008 14:18 > *To:* [email protected] > <mailto:[email protected]> > *Subject:* [JSch-users] StrictHostKeyChecking =true > > Hi All, > > I am trying to perform Server authentication. I have set > "StrictHostKeyChecking" to yes. I understand that the hostkey of the > server has to be obtained before hand and store in the hostkey file > before the first attempt to connect to the server. How can I get the > HostKey of the server by any external entity? > > Is there any format to which the hostkey in the hostkey file must > adhere to? Since I see that the hostkey stored in the hostkeyfile > will be in a hash of the server FingerPrint. > > Can anyone please provide some information on this. > > Thanks > Srikanth > > ____________________________________ > This e-mail may be privileged and/or confidential, and the sender does > not waive any related rights and obligations. Any distribution, use or > copying of this e-mail or the information it contains by other than an > intended recipient(s) is unauthorized. If you received this e-mail in error, > please advise me (by return e-mail or otherwise) immediately and delete this > e-mail. > > The contents of any attachment to this e-mail may contain software > viruses or other defect which might affect your own computer system once > received or opened. While companies under RBC Dexia Investor Services Trust > and its affiliates take reasonable precautions to minimize that risk, we > cannot accept liability or responsibility for any damage or loss which may > occur or be sustained as a result of a software virus or other defect. You > are responsible for virus checks before opening any attachment. > > > > > -- > impossible says "I'M POSSIBLE" > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ JSch-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jsch-users
