Тёмный

Download and Upload Files from SFTP Servers from Java Applications using the JSch library 

Productivity for Programmers
Подписаться 1,2 тыс.
Просмотров 22 тыс.
50% 1

In this video I'll cover how the following SFTP operations can be performed by a Java program using the JSch library:
- Connecting to SFTP servers
- Authenticating to SFTP servers
- Listing directories
- Changing directories
- Downloading files
- Uploading files
I also cover how to handle the following errors:
- com.jcraft.jsch.JSchException: invalid privatekey
- com.jcraft.jsch.JSchException: UnknownHostKey
- com.jcraft.jsch.JSchException: Auth fail
While not necessary, if you enjoyed this video, buying me a coffee is greatly appreciated!
www.buymeacoffee.com/prodprog... (no refunds)
Introduction: (00:00)
Connection to the SFTP Server: (00:37)
Dealing with UnknownHostKey error: (01:26)
Authentication: (05:38)
Creating the SFTP Channel: (10:41)
Listing and Changing Directories: (12:25)
Downloading Files: (15:30)
Uploading Files: (16:58)
Conclusion: (19:45)
Source Code from Video Main.java:
gist.github.com/productivity-...

Опубликовано:

 

21 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@borisbritva152
@borisbritva152 3 года назад
Nice , very simple and affordable!!
@krishnac6559
@krishnac6559 Год назад
Thank you bro
@FocusYT155
@FocusYT155 2 года назад
best asmr content : D
@explore.nature13
@explore.nature13 Год назад
very helpful video
@ProductivityforProgrammers
@ProductivityforProgrammers Год назад
Thank you! I'm glad to hear that.
@pavanvhsn
@pavanvhsn 2 года назад
Great video. I get Auth Fail when the password contains special characters. I tried escaping the special character and the issue is not resolved. Any leads here would help. Thanks
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
I don't have a solution for you at the moment but thank you for alerting me about this issue.
@rrai2008
@rrai2008 3 года назад
How would one download the file using a web application to my local machine?
@ProductivityforProgrammers
@ProductivityforProgrammers 3 года назад
Assuming that your scenario is something like this: local machine (web browser) --> web application --> SFTP If you're using Java servlets you can do something like this to send the file to the web browser after you have downloaded it from the SFTP server: stackoverflow.com/a/14281064
@rounakdas3411
@rounakdas3411 Год назад
are you using virtualbox to create a windows virtual environment?
@ProductivityforProgrammers
@ProductivityforProgrammers Год назад
Yes that's correct
@jamesanthonydejesuscasasch5470
@jamesanthonydejesuscasasch5470 3 года назад
Hello, how could I transfer files between two remote folders on the SFTP server?
@ProductivityforProgrammers
@ProductivityforProgrammers 3 года назад
Try using the rename() function but use absolute paths.
@ProductivityforProgrammers
@ProductivityforProgrammers 3 года назад
Let me know if that works for you
@user-jv3rd5dr5z
@user-jv3rd5dr5z 4 месяца назад
Hi bro, when I try to download the file using get method, instead of getting copy of the file, getting deleted in server.Please suggest on how this issue can be fixed.
@ProductivityforProgrammers
@ProductivityforProgrammers 3 месяца назад
Hello, did you solve your problem yet? I would test this using another SFTP tool first to see whether it has the same behavior - if it does, then it's something to do with the server.
@ramansharma5014
@ramansharma5014 2 года назад
getting error com.jcraft.jsch.JSchException: timeout: socket is not established
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
Are you able to connect to the server from this machine using the command line tools - ssh or sftp?
@archnamonga7138
@archnamonga7138 2 года назад
You mentioned about a new library that you will be doing a new video on it.. can you share the link of that
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
github.com/hierynomus/sshj I'll be doing a video on it before the end of the year.
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
I just published the video a few days ago - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ySCcZa9Y-Zw.html
@shehazshefy
@shehazshefy 3 года назад
Hey, do you have the code in github?
@ProductivityforProgrammers
@ProductivityforProgrammers 3 года назад
I overlooked this, I just added it to the video description. Thanks for alerting me.
@shehazshefy
@shehazshefy 3 года назад
Thanks mate 👍
@romulobeltran6394
@romulobeltran6394 2 года назад
is it also working in java with ant?
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
Yes, shouldn't be an issue building with ant. If you're having trouble getting all the dependencies you might want to look into using Apache Ant with Ivy
@romulobeltran6394
@romulobeltran6394 2 года назад
@@ProductivityforProgrammers is that applicable in netbeans? Or is that another app or IDE to use?
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
I'm using IntelliJ. For other IDEs it should be similar.
@rajeshcr9800
@rajeshcr9800 12 дней назад
Car user... This command not working in windows
@ProductivityforProgrammers
@ProductivityforProgrammers 6 дней назад
Hello, what do you mean by ‘car user’
@diegoherrera2358
@diegoherrera2358 2 года назад
I want to implement this using scp protocol
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
I haven't explored using scp yet. Is there any reason you can't use sftp?
@diegoherrera2358
@diegoherrera2358 2 года назад
@@ProductivityforProgrammers is to automate the set up of an embedded device. It doesn't have sftp.
@rafs250
@rafs250 2 года назад
Great video with clear explanation, thanks. We're in a case where we only need to read the first line (header), after reading the first line, we close the stream but we got an IOException. After couples of tries, we found that if we read all the file, we don't get the exception, do you have an idea ? Exception : at com.jcraft.jsch.ChannelSftp$2.close(ChannelSftp.java:1532) ~[jsch-0.1.55.jar:na] Thanks for your help 🙂
@ProductivityforProgrammers
@ProductivityforProgrammers 2 года назад
Are you ensuring that you close the InputStream after reading the first line?
Далее
SFTP File Transfer using Java JSch
11:05
Просмотров 17 тыс.
TLS Handshake Explained - Computerphile
16:59
Просмотров 550 тыс.
Spring Boot and Sftp - Avoid ftp and ftps if possible
18:11
An Illustrated Guide to OAuth and OpenID Connect
16:36
Просмотров 567 тыс.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
Просмотров 875 тыс.