jsch

jsch and running “sudo su -”

南笙酒味 提交于 2019-12-01 21:26:44
Using jsch when i run the following cmd 'sudo su -' the program hangs [TestNG] Running: C:\Users\brian.crosby\AppData\Local\Temp\testng-eclipse-952620154\testng-customsuite.xml [root@tbx2-toy-1 ~]# It looks like the "sudo su -" worked becasue the output states "[root@tbx2-toy-1 ~]#" but when i send it another cmd it is unresponsive. heres the code: package com.linux; import java.io.InputStream; import org.testng.annotations.*; import com.jcraft.jsch.*; import com.thoughtworks.selenium.*; public class LinuxConnection extends SeleneseTestBase{ String host = null; private StringBuilder

JSch: UnknownHostKey exception when Host Key is in known_hosts AND after adding JCE

巧了我就是萌 提交于 2019-12-01 18:18:38
问题 I've been working with JSch for a project, connecting to a Unix server. Having some trouble connecting to a server using ecdsa-sha2-nistp256 for the key exchange. The odd thing is, I've enabled JCE (Using JDK 1.8 65) from this post but still no dice. If I'm reading the logs correctly, the client does have ecdsa-sha2-nistp256 enabled. But it falls back to ssh-rsa. Perhaps I missed a step? The error: UnknownHostKey: *********. RSA key fingerprint is 1d:ac:f7:50:10:07:51:4b:17:9c:cd:b5:be:25:75

setConfig(Properties) in the type Session is not applicable for the arguments (String, String)”

浪子不回头ぞ 提交于 2019-12-01 15:02:42
This question has already been asked here: "The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String)" more than a year ago but it doesn't have any answer and I have the same problem just now. Unfortunately I didn't find anything more on Google. import com.jcraft.jsch.*; import java.io.*; import java.util.Properties JSch jsch = new JSch(); String user = "myUserId"; String host = "myHost"; Session session = jsch.getSession(user, host, 22); session.setConfig("StrictHostKeyChecking", "no"); My code is as simple as that and I have the following

Make FileAlterationObserver to observe remote directory

一世执手 提交于 2019-12-01 14:37:24
How to make FileAlterationObserver to observe a remote directory? This can accept a String path or a Java File . Both the cases it will look for the directory in local context. I have a directory in remote server file system. It would be also helpful if anyone tell me how to create a new File object referring to the file in the remote directory. Example: File file = new File("remote directory path"); You cannot. The File object cannot refer to an SFTP file. There's no way to have the SFTP server notify you on changes in a remote file/directory (the protocol itself does not have a mechanism for

Jsch and sudo command

青春壹個敷衍的年華 提交于 2019-12-01 14:16:00
I am trying to automate some operations and one of such an operation is switching to a technical user on a remote Linux machine. The procedure looks like this: log in with a "normal" user and then switch with sudo /bin/rootsh -i -u techUser to the technical user. Here's my Groovy code example that I am working on: import com.jcraft.jsch.JSch import com.jcraft.jsch.Session import com.jcraft.jsch.Channel import com.jcraft.jsch.ChannelExec import com.jcraft.jsch.JSchException class Main { static void main(String[] args) { int responseCode = 0 String responseText = "" def targetHost = "targetHost"

“Algorithm negotiation fail” error in JSch when trying to connect to Symantec NetBackup - grabing reports remotely

一世执手 提交于 2019-12-01 13:46:49
I have been searching online and found similar posts but could not find a solution reading them. I am trying to connect to NetBackup servers using ssh from my computer and run a report and create graphs based on them. I am doing this using java and JSch library. The problem is that I get: "Algorithm negotiation fail" at com.jcraft.JSch.Session.recieve_kexinit(... I know very little about negotiations and keys and different methods such as diffie-hellman etc. Could you please tell me: 1. How can I find out what methods does the server accept? 2. If I need to set up a negotiation method, how

Memory leak using while uploading and downloading a file (may be because of using ChannelSftp.get( “file_name”) )?

六眼飞鱼酱① 提交于 2019-12-01 13:39:15
Can you please tell the internal working of ChannelSftp.get( "file_name") ? Will the use of this function to get a single file from a list of files (600 files of 10 kb) can cause memory leakage issues in Tomcat8, if this function is used frequently? This is the code which is used for uploading and fetching files from remote server. public String connectRemote(String host, String user, String password, String remotePath, String sFileName) throws IOException, JSchException, SftpException { try { String sFileNames =""; Session session = connectSFTP(host, user, password); Channel channel = session

Certain Unix commands fail with “… not found”, when executed through Java using JSch even with setPty enabled

女生的网名这么多〃 提交于 2019-12-01 13:29:30
I'm creating an android app that sends commands to a linux terminal on a device. I am able to get the proper output when using the "ls" command, however the device does not give me any output when I use "ifconfig" or "iwconfig". Using Tera Term, I have verified these commands do work. I have tried including ((ChannelExec)channel).setPty(true); in order to fix this, however the terminal still appears to not recognise the command. Adding that line of code also changes my output for the "ls" command to something I do not recognise. This is my JSch code: package com.example.riot94

Make FileAlterationObserver to observe remote directory

纵然是瞬间 提交于 2019-12-01 12:57:50
问题 How to make FileAlterationObserver to observe a remote directory? This can accept a String path or a Java File . Both the cases it will look for the directory in local context. I have a directory in remote server file system. It would be also helpful if anyone tell me how to create a new File object referring to the file in the remote directory. Example: File file = new File("remote directory path"); 回答1: You cannot. The File object cannot refer to an SFTP file. There's no way to have the

How to read the SSH key-sig pair banner (for generating SSH password) after connecting to host in Java?

夙愿已清 提交于 2019-12-01 12:55:52
I want to read the the SSH key-sig pair banner (for generating SSH password) after connecting to a remote host in java. I'm using JSch client library for SSH connections. The SSH password changes after certain operations on the host, hence each time I need to generate a new SSH password from the key-sig pair to login. Is there a way that I can read the banner programmatically? Below is a snippet of the key-sig pair banner coming up with the password prompt when trying to SSH through client console (PuTTY). NbwDZIAGjGS90zisB+jY9Kqrmu67PyMwas6S6jY68f+QL4l+TJDyHWUTGtzluflwY+z