Sorry for a double reply. I had one other question.

Is there any way for me to not have it use this authentication or need the keys? I've got a username and password on the system I'm SFTPing into so I don't see why I also need an SSH key. Especially because I just hit enter and don't actually answer the two Kerberos questions when they're asked. I just want to SFTP in, provide the username and password, and do my thing. Not even sure if I'll be able to get access to add keys.

Regardless, thanks for your help.

On Mon, Jun 4, 2012 at 10:03 AM, Cardician <cardician@gmail.com> wrote:
Thanks very much. I wasn't sure if that's what I was missing so I wasn't sure if I should attempt to implement something like that. Much appreciated.


On Mon, Jun 4, 2012 at 9:59 AM, Benjamin L. May <blm14@columbia.edu> wrote:

You can create public/private keys on the originating server (using ssh-keygen), copy the public key into the remote host's .ssh/authorized_keys and then pass the private key in as a runtime paramater on the originating machine.

There are examples of this all over the web, but one is here :)

http://stackoverflow.com/questions/4932005/can-we-use-jsch-for-ssh-key-based-communication


On Mon, 4 Jun 2012, Cardician wrote:


So I'm writing a little program that needs to connect to a remote server
through SFTP, pull down a file, and then processes the file. I came across
JSch through some answers on StackOverflow and it looked perfect for the
task. So far, easy to use and I've got it working, with one minor thing I'd
like to fix. I'm using the following code to connect and pull the 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 this works and I get the file. I'm running this code on a linux server
and when I run the code JSch asks me for my Kerberos username and password.
It looks like:

Kerberos username [george]:

Kerberos password for george:

I just hit enter for both questions and then the program seems to continue
on with no problems. However I need this code to be automated through a cron
task and so I'd rather not having it pausing the program to ask me these two
questions. Is there something I'm not supplying it so that it won't ask
this? Something I need to do to stop it asking? Hopefully someone has some
ideas. Thanks.




Sincerely,
Ben May
Senior Research Analyst
Herbert Irving Comprehensive Cancer Center
212-851-4772