I'm looking for java code to copy files to a remote linux system. I have tried Runtime.getRuntime().exec()
function by passing an scp
command, but each time I run the program it is asking for the remote system password. I'd like to avoid that.
I looked at the Jsch
library -- using this I can login to a remote system -- but I can't copy the files to the remote system. Once I login I can do scp
to my host but again it requires the host system username and password. However, I only have the remote system's information.
Jsch
library withsftp
channel.And for the very first time I'll be having the credentials of the remote system so I don't have any issues in login.And then as suggested by @SamiLaine I copied my public key and my actual files(the files which I actually wanted to copy) to remote system.So for the next time while copying it didn't asked for any password. :)