jsch

Executing a command using JSch

落爺英雄遲暮 提交于 2019-12-10 11:27:38
问题 I'm using JSch to automate remotely launching a python script from a background Java process. Modifying the Shell.java example included in the JSch package, I've successfully installed JSch, connected to my Pi, and even commented out the user/domain/password/host key checking prompt boxes in favor of storing these values directly in my Java code. After my java code logs into the remote Pi, I'd like it to send something like sudo nohup python2 myFoo.py & disown to the terminal. In the Shell

How to reput on JSch SFTP?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:27:29
问题 I'm using JSch to upload files to a SFTP. It works but sometimes the TCP connection is shut down while a file is being uploaded resulting on a truncated file on the server. I found out that the reput command on SFTP servers resumes the upload. How can I send a reput command with JSch? Is it even possible? Here's my code: public void upload(File file) throws Exception { JSch jsch = new JSch(); Session session = jsch.getSession(USER, HOST, PORT); session.setPassword(PASSWORD); java.util

JSCH会大量使用服务器内存吗?会

佐手、 提交于 2019-12-10 03:13:46
java实现一个需求用到了jsch,发现服务器内存会被占满。 写了个50进程的jsch-sftp测试连接 put一个文件 ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50); for (int j = 0; j < 50; j++) { fixedThreadPool.execute(new Thread("Thread1") { [@Override](https://my.oschina.net/u/1162528) public void run() { while (true){ System.out.println(Thread.currentThread().getName()); dosftptest(); try { Thread.sleep(10*1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }); } total used free shared buff/cache available Mem: 1839 137 828 0 873 1523 Swap: 0 0 0 total used free shared buff/cache available Mem: 1839 748 123

JSch get() fails with NullPointerException

妖精的绣舞 提交于 2019-12-09 23:55:57
问题 I've got a Jax-RS server which is supposed to keep a list of files accessible via ssh that I can then download or stream via HTTP. I've been trying to read the files with JSch's SFTP channel, but I keep receiving a NullPointerException . Here's the MessageBodyWriter I wrote: @Provider @Produces("video/*") public class MediaBodyWriter implements MessageBodyWriter<MediaFile> { @Override public long getSize(MediaFile mFile, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4) { return

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

南笙酒味 提交于 2019-12-09 23:29:33
问题 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

what's the exact differences between jsch ChannelExec and ChannelShell?

痞子三分冷 提交于 2019-12-09 16:51:58
问题 Can someone tell me the differences between ChannelExec & ChannelShell ? 回答1: The shell and exec channels are quite similar - both execute commands with the remote shell (at least, conceptually - the server might be configured to treat them differently, of course). RFC 4254 groups them in the section "Interactive Sessions", and they both (as well as subsystem, see below) use the channel type "session" in the SSH protocol. There is one important difference: For ChannelShell, the input stream

teamcity aes256-cbc error when retrieving git repository

六眼飞鱼酱① 提交于 2019-12-09 14:41:02
问题 I've just installed Teamcity 8.0.3 on a fresh Windows Server 2012 machine. Installation was successful, and I'm trying to configure an agent in order to fetch a project stored in a git server. This server uses a ssh key. I've added it to my agent, but when it tries to retrieve the project this error appears. Failed for the root 'rtogit' #1: List remote refs failed: com.jcraft.jsch.JSchException: The cipher 'aes256-cbc' is required, but it is not available. I've seen, for example here that I

How can I access an FTP server with JSch?

家住魔仙堡 提交于 2019-12-09 10:08:57
问题 I installed FileZilla FTP Server on my local Windows 7 machine. I also installed FileZilla FTP client on the same machine. Connection is successfull between both of them confirming the server and client partnership exists. I wrote a small quick and dirtry Jsch program for connecting to the FileZilla FTP server and below is the program: public class TestJSch { /** Creates a new instance of TestCommonsNet */ public TestJSch() { } /** * main - Unit test program * * @param args * Command line

Retrieving data from an SFTP server using JSch

我怕爱的太早我们不能终老 提交于 2019-12-09 06:02:59
问题 I am using JSch for retrieving a file from a remote machine by SFTP. Here is the code public class TestSFTPinJava { public static void main(String args[]) { JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession("username", "sftp.abc.com", 22); session.setConfig("StrictHostKeyChecking", "no"); session.setPassword("password"); session.connect(); Channel channel = session.openChannel("sftp"); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; System.out

Getting MD5 checksum on the remote server using JSCH

雨燕双飞 提交于 2019-12-09 01:38:17
问题 I am writing a application where the requirement is to transfer files from a remote SFTP server to the local machine and vice - versa. During the file transfer I want to make sure that no data packets are lost and corrupted in the transit.So the idea is to run a MD5 checksum on the remote file (residing in the sftp server) before the transfer and then start the transfer process. Once the transfer is done, run a md5 on the local file and compare the two checksums. I am using JSCH to connect to