Hi Hanuman, If the remote machine is windows: For sftpPath use: "/C:/Users/file.txt" For local path based on your OS, you can use windows style or Linux style path: For Windows: "C:\\Users\\file.txt" or "C:/Users/file.txt" both will work For Linux: "/home/users/user1/file1.txt" will work. Let me know if it worked or not? Thanks, Gaurav
Hi Voruganti, I don't know about Linux but for windows, you can do it. But you have to give the local path as "/C:/". Note the "/" before C: One tip to understand the structure of local and remote side paths for SFTP, use the popular software WinSCP and notice the remote and local paths there. Thanks, Gaurav
Very simple and effective code with good explanation.. thanks sir 🙏
very simple and direct code thanks
Awesome explanation. I get Auth Fail from Jsch library when the password contains "+". Any solution for this?
How to get the file in another server instead of local?
Same code NOT working for RHEL 8 server, May i know how to connect RHEL8 server with Java code JSch
Can you show us how to login with private key?
How to specify the localPath if we are developing on windows machine.
Somehow C:\\Users\\file.txt - This isn't working
Hi Hanuman,
If the remote machine is windows:
For sftpPath use: "/C:/Users/file.txt"
For local path based on your OS, you can use windows style or Linux style path:
For Windows: "C:\\Users\\file.txt" or "C:/Users/file.txt" both will work
For Linux: "/home/users/user1/file1.txt" will work.
Let me know if it worked or not?
Thanks,
Gaurav
@@ggaur10 Thanks Gaurav, this worked on windows machine. Appreciate your response.
How can we transfer files from one path to another path in the same Unix server using SFTP. can we follow the same process??
did you get an answer for this question?
@@emadsamir6092 noo
Hi Voruganti,
I don't know about Linux but for windows, you can do it. But you have to give the local path as "/C:/". Note the "/" before C:
One tip to understand the structure of local and remote side paths for SFTP, use the popular software WinSCP and notice the remote and local paths there.
Thanks,
Gaurav
how to move a file instead of copying?
You can first copy the file then check the checksum in source and target. Then delete the file from SFTP server
java version 6 error com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:582)
How did you resolve the error I am also facing the same issue please help