Copy files using jsch without password.

Help
2010-11-11
2013-05-28
  • Narasimha Rao
    Narasimha Rao
    2010-11-11

    Is it possible to use jsch to copy the files in unix environment without password.

    The requirement is - Java program will be running on 'Host1' with 'User1'. This java program has to copy/scp the files from "host1' machine to 'Host2' machine.

    I use the below command to scp the files from 'Host1' to 'Host2' in Unix environment.
    1) Login to 'Host1' with 'User1'
    2) Public keys are already exchanged between 'Host1' and 'Host2' for 'User1' and 'user2'
    3) scp 'Test_File.txt' USER2@HOST2:/dir1/dir2/dir3  -> This command with copy the file 'Test_File.txt' from 'Host1' to 'Host2' without prompting for any passwords.

    I would like to achive same using jsch. If it is possible, can someone give me the example.

    Thanks in Advance,
    Narasimha Rao.