jsch

Setting ASCII mode in Jsch

陌路散爱 提交于 2019-12-05 19:42:52
I need to overcome a Unix - Windows file format (LF to CRLF) issue I'm currently having. The ftp client I am using is Jsch from Jcraft. The documentation online is very bare, although I have come across a flag that can be set SSH_FXF_TEXT_MODE that enables ASCII mode, but I don't see where I should set this in the code itself, nor do I see it mentioned in these Javadocs Below is my own attempt at a workaround. The "Newly Added" line shows how I take the file and convert it to an ASCII encoded string, which I then transfer across using the channelSftp put method. Originally I would have just

What's wrong with Jsch and Maven?

吃可爱长大的小学妹 提交于 2019-12-05 19:31:30
I try to use Jsch 0.1.44 together with Maven. I have the following dependency in my pom.xml. <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.44</version> <scope>compile</scope> </dependency> If I run mvn compile maven looks normal and tells me that Jsch has been successful downloaded. But when it comes to compile, the Jsch classes could not be found. If I look into my local repository I can see that the Jsch-jar has only a size of 3kb. If I open the jar file I can also see that there is only the META-INF folder. So what is wrong here, how can I fix this?

Why does reading from a shell channel output in JSch never end with -1?

ⅰ亾dé卋堺 提交于 2019-12-05 18:36:58
I created an object called Obj which sends messages over a Secure Shell channel. I can send characters in UTF-8, which means that the output stream must handle multi-byte characters. That is why I decided to use a buffered output stream writer. That is not relevant, so the code only references that part of the code with a comment. I'd like the input stream to also handle multibyte characters. I know that the read() function of the InputStreamReader will return integers that correspond to UTF-16 code points or -1. My current implementation loops and tests for -1. It loops endlessly. Why? Code

Move a directory in remote server to another location in the same remote server using jsch

↘锁芯ラ 提交于 2019-12-05 16:25:49
I am using JSCH API to connect to remote server through sftp. I need to move a directory present in the remote server from location A to location B. It looks like the method channelsftp.put(src,dest) allows to move only a file and not the directory. Can someone please explain me how to do this? You can use the rename command, it would move the file or directory and delete it from the original place. sftpChannel.rename(oldFile, newFile); Don't use this method, if you want to keep the original directory/file. Hope this helps. 来源: https://stackoverflow.com/questions/13277218/move-a-directory-in

How to connect to an FTP server from an existing connection to Unix server?

不羁的心 提交于 2019-12-05 08:02:40
问题 Currently I am using Reflection for Unix and OpenVMS. I connect to a Unix server. Once connected, I establish a new FTP connection to the target server. Here is how the console window look like: login: xxx Password : xxx // Now I'm connected to UNIX // Next I am connecting to that FTP ftpLogin@hostName :/whatever/.../ $ ftp someftp.example.com Conencted Name: myLogin Password: XXX Login OK I tried to replicate the same steps programmatically, but got confused with this "double connection"

Java 1.7 + JSCH: java.security.InvalidKeyException: Key is too long for this algorithm

雨燕双飞 提交于 2019-12-05 02:03:25
I'm trying to use JSCH to upload a file to a remote SFTP share. Every time I attempt to connect to the share from within my code, I get an exception that looks something like this: com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidKeyException: Key is too long for this algorithm at com.jcraft.jsch.Session.connect(Session.java:558) ~[jsch-0.1.51.jar:na] at com.jcraft.jsch.Session.connect(Session.java:183) ~[jsch-0.1.51.jar:na] I've seen posts that describe this error when upgrading to Java 8, but we're still on Java 7, and I don't know enough about Java's cryptography support

Is multipart file upload possible with SFTP JSch library?

…衆ロ難τιáo~ 提交于 2019-12-04 20:38:32
I want to upload a very big size file which can be of size 1 GB . Is it possible to upload or download it to/from SFTP server? I am using JSch library. Your question does not really make sense. You seem to make some assumptions that are not true. But it's hard to tell, what those are, as your question is rather sparse. "Multipart upload" is a term used with other protocols. Those are usually HTTP-based protocols (like S3, REST, etc), as HTTP have problems with uploading large files. For example firewalls between the client and server may not allow an HTTP connection to stay open long enough

Wait for JSch command to execute instead of hard coding a fixed time to wait for

六眼飞鱼酱① 提交于 2019-12-04 20:29:56
Channel channel=session.openChannel("shell"); channel.setInputStream(System.in); channel.setOutputStream(System.out); channel.connect(); while (channel.getExitStatus() == -1){ try{Thread.sleep(1000);}catch(Exception e){System.out.println(e);} } channel.disconnect(); In the code above we add line Thread.sleep(1000); to give the system enough time, to execute the command. However when I change the time gap from 1000 ms to 200 ms , the command doesn't execute. Also in some slow servers, the command may not execute for the specified time gap of 1000 ms too. Is there any other dynamic way to wait

Problems with Ant optional tasks SSHExec and SCP. Classpath issue?

醉酒当歌 提交于 2019-12-04 20:17:17
I'm in the process of modifying an Ant script (currently in use from within MyEclipse) to work from the command line. I'm doing this so anyone can check out the project and build it without MyEclipse. The problem I'm running into is that MyEclipse includes the dependencies behind the scenes. It does this by looking at the workspace's Ant configuration and compiling the classpath based on the selected libraries in the preferences dialog. Long story short, I need to take those dependencies and make the script smart enough to include them on its own, without the help of MyEclipse. The tasks that

How can I run an application on a remote machine by ssh?

谁说胖子不能爱 提交于 2019-12-04 20:06:41
How can I run an application on a remote machine via ssh? I tried using JSCH, this way: Properties props = new Properties(); props.put("StrictHostKeyChecking", "no"); String host = "111.111.11.111"; String user = "myuser"; String pwd = "mypass"; // int port = 22; JSch jsch = new JSch(); Session session = jsch.getSession(user, host); session.setConfig(props); session.setPassword(pwd); session.connect(); System.out.println(session.getServerVersion()); System.out.println("Conected!"); // String command = "ps -ef;date;hostname"; String command = "myapplication someFileAsParameter"; Channel channel