jsch

Running linux commands on java through JSch

自作多情 提交于 2020-01-21 05:18:04
问题 I'm establishing a ssh connection through JSch on java and everything seemed to be working fine, until I tried to run this .sh file. The shell script's name is repoUpdate.sh and it's very simple: echo ' ****Repository update****' echo ' Location: /home/cissys/repo/' echo -e ' Command: svn update /home/cissys/repo/2.3.0' svn update /home/cissys/repo/2.3.0 This is the output I get directly on the linux console with the proper response of the command: [cissys@dsatelnx5 ~]$ repoUpdate.sh ***

Java8 + Jcraft = Key is too long for this algorithm

社会主义新天地 提交于 2020-01-15 07:37:26
问题 We are using JCraft / Jsch for sftp file transfer. http://www.jcraft.com/jsch This has worked excellent for several years with Java6 and Java 7. But then we upgraded to Java 8 and it worked fine in our test environment, but it failed in our QA environment. Then it failed against a remote SFTP server. This SFTP server uses 'SSH-2.0-4.2.0.21 SSH Secure Shell Windows NT Server' We have no control over this server. I googled a little and found out that some suggests that the source of the problem

com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect

不羁的心 提交于 2020-01-13 19:57:29
问题 I understand that there is duplicate >>> copied from the duplicate >>>As long as your local machine has an SSH server running <<<<< but i cannot comment and cannot as from the question (and im not providing an answer....) It stated that "As long as your local machine has an SSH server running" but I do not know how to have a SSh server running. I turn on my putty (double click on it) (not sure if this means the SSH(?Putty?) server (?) is running... doubt so... im really new to socket

How to transfer a file using a proxy with JSch library

狂风中的少年 提交于 2020-01-13 02:53:07
问题 I want to transfer files to a remote location and I am bound to use a proxy server for that. I was able to connect to the FTP location via following command : sftp -o "ProxyCommand /usr/bin/nc -X connect -x <proxy_host>:<proxy_port> %h %p" username@ftp_server: But I want to automate this process of file transfer and I am using JSch for SFTP and snippet of code is below: String sourceFile = sourceDir + fileName; JSch jsch = new JSch(); int port = Integer.parseInt(getFtpPort()); Session session

Use JSch to put a file to the remote directory and if the directory does not exist, then create it

核能气质少年 提交于 2020-01-12 01:33:29
问题 I would like to copy a file to the remote directory using Jsch library and SFTP protocol. If the directory on the remote host does not exist, then create it. In the API doc, http://epaul.github.com/jsch-documentation/javadoc/, I noticed in the put method that there is a kind of "mode" but it is just the transfer mode: - the transfer mode, one of RESUME, APPEND, OVERWRITE. Is there an easy way to do this without having to write my own code to check the existence and then create a directory

Use JSch to put a file to the remote directory and if the directory does not exist, then create it

坚强是说给别人听的谎言 提交于 2020-01-12 01:33:06
问题 I would like to copy a file to the remote directory using Jsch library and SFTP protocol. If the directory on the remote host does not exist, then create it. In the API doc, http://epaul.github.com/jsch-documentation/javadoc/, I noticed in the put method that there is a kind of "mode" but it is just the transfer mode: - the transfer mode, one of RESUME, APPEND, OVERWRITE. Is there an easy way to do this without having to write my own code to check the existence and then create a directory

How can I enable passive mode while using JSch as SFTP client?

坚强是说给别人听的谎言 提交于 2020-01-11 06:03:46
问题 I'm using JSch as SFTP client and now I need to enable passive mode because of some limitation of security. But I can not found a way to enable passive mode . Can somebody tell me how to do this? 回答1: "Passive mode" is a specialty of the FTP protocol. In normal FTP mode for each individual file the client listens on a port and the server has to connect to this. As many firewalls support only outgoing connections, there was added the passive mode - here the client connects to the server for

How can I enable passive mode while using JSch as SFTP client?

狂风中的少年 提交于 2020-01-11 06:03:19
问题 I'm using JSch as SFTP client and now I need to enable passive mode because of some limitation of security. But I can not found a way to enable passive mode . Can somebody tell me how to do this? 回答1: "Passive mode" is a specialty of the FTP protocol. In normal FTP mode for each individual file the client listens on a port and the server has to connect to this. As many firewalls support only outgoing connections, there was added the passive mode - here the client connects to the server for

Take commands(password) from string and set as InputStream to Unix servers in Java (JSCH)

六眼飞鱼酱① 提交于 2020-01-10 05:58:51
问题 Almost similar to this topic, but here I am not a superuser to use --stdin. So I found an other way round, I would open a "shell" in background and give input to shell via a String through InputStream I made a code like below: String s = "cd bin\n"; byte bb[] = s.getBytes(); InputStream intt = new ByteArrayInputStream(bb); channel.setInputStream(new FilterInputStream(intt) { public int read(byte[] b, int off, int len) throws IOException { return in.read(b, off, (len > 1024 ? 1024 : len)); } }

Multiple commands using JSch

夙愿已清 提交于 2020-01-09 05:29:25
问题 My requirement is as follow: I have to login to Unix box using my credentials and once login, I have to do sudo to different user. Once sudo is successful, I have to invoke shell in nohup. On completion of executions, close channel and session both. I tried the first step which is connect using sudo command, but I don't know how to invoke shell script after the sudo command. In the below code I am able to execute sudo command, but after getting sudo access how can I execute a shell in nohup