SFTP connection through Java asking for weird authentication -


so i'm writing little program needs connect remote server through sftp, pull down file, , processes file. came across jsch through answers here , looked perfect task. far, easy use , i've got working, 1 minor thing i'd fix. i'm using following code connect , pull file down:

    jsch jsch = new jsch();     session session = null;     try {         session = jsch.getsession("username", "127.0.0.1", 22);         session.setconfig("stricthostkeychecking", "no");         session.setpassword("password");         session.connect();          channel channel = session.openchannel("sftp");         channel.connect();         channelsftp sftpchannel = (channelsftp) channel;         sftpchannel.cd(remote_ftp_dir);         sftpchannel.lcd(incoming_dir);         sftpchannel.get(tmp_file, tmp_file);         sftpchannel.exit();         session.disconnect();     } catch (jschexception e) {         e.printstacktrace();     } catch (sftpexception e) {         e.printstacktrace();     } 

so works , file. i'm running code on linux server , when run code jsch asks me kerberos username , password. looks like:

kerberos username [george]:

kerberos password george:

i hit enter both questions , program seems continue on no problems. need code automated through cron task , i'd rather not having pausing program ask me these 2 questions. there i'm not supplying won't ask this? need stop asking? has ideas. thanks.

thought i'd post answer here since in case else ends running similar issue. turns out missing piece of code makes difference. needed add

session.setconfig("preferredauthentications",                    "publickey,keyboard-interactive,password"); 

before

session.connect(); 

and works now.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -