jsch

Algorithm negotiation fail SSH in Jenkins

陌路散爱 提交于 2019-11-27 04:12:12
I'm trying to ssh from Jenkins to a local server but the following error is thrown: [SSH] Exception:Algorithm negotiation fail com.jcraft.jsch.JSchException: Algorithm negotiation fail at com.jcraft.jsch.Session.receive_kexinit(Session.java:520) at com.jcraft.jsch.Session.connect(Session.java:286) at com.jcraft.jsch.Session.connect(Session.java:150) at org.jvnet.hudson.plugins.SSHSite.createSession(SSHSite.java:141) at org.jvnet.hudson.plugins.SSHSite.executeCommand(SSHSite.java:151) at org.jvnet.hudson.plugins.SSHBuildWrapper.executePreBuildScript(SSHBuildWrapper.java:75) at org.jvnet.hudson

How to read JSch command output?

孤人 提交于 2019-11-27 04:08:22
I have the following code: JSch jsch = new JSch(); jsch.setKnownHosts(dotSshDir + "/known_hosts"); jsch.addIdentity(dotSshDir + "/id_rsa"); Session session = jsch.getSession(userName, hostname, 22); session.connect(); ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); channel.setInputStream(null); channel.setErrStream(System.err); Reader reader = new InputStreamReader(channel.getInputStream()); char[] buf = new char[1024]; int numRead; while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); result.append

How to get jsch shell command output in String

心不动则不痛 提交于 2019-11-27 04:01:22
问题 I am using a JSCH -SSH library to execute command in "shell" channel, but unable to find a way to do 2 things:- 1) How to find whether the command is completely executed on remote unix box ? 2) How to capture the command output in String , instead of printing it on System.out console ? Below is my code snippet which works fine to display shell command output on system.out NOTE :I do NOT want to use ,"exec" channel, as it starts a new process for each command and does not remember "session"

Explanation for SCP protocol implementation in JSch library

邮差的信 提交于 2019-11-27 03:45:11
问题 I am contemplating over an example of JSch library usage which can be found here: http://www.jcraft.com/jsch/examples/ScpFrom.java.html I cannot understand several code patterns from this example. Here they are: Is there any reasons to prefer SCP over SFTP, which can be ran using the same library? Why we run scp -f <remote file> on remote host instead of running simply scp source_file_path destination_file_path ? Why execution on remote host is better? In the beginning of the transfer there

Never ending of reading server response using jSch

折月煮酒 提交于 2019-11-27 01:56:29
I am trying to run commands at unix server by connecting through jSch0.1.49 library. I have gone through the samples provided by jSch and even http://sourceforge.net/apps/mediawiki/jsch/index.php?title=Official_examples I am able to read the response from the server and printed it to console but the loop is * never endin *g. I doubt why the Channele is not closing once it is finished reading response from server. while (true) { while (inputStream.available() > 0) { int i = inputStream.read(buffer, 0, 1024); if (i < 0) { break; } System.out.print(new String(buffer, 0, i));//It is printing the

JSchException: Algorithm negotiation fail

て烟熏妆下的殇ゞ 提交于 2019-11-27 01:31:27
I am trying to connect to remote sftp server over ssh with JSch (0.1.44-1) but during "session.connect();" I am getting this exception: com.jcraft.jsch.JSchException: Algorithm negotiation fail at com.jcraft.jsch.Session.receive_kexinit(Session.java:529) at com.jcraft.jsch.Session.connect(Session.java:291) at com.jcraft.jsch.Session.connect(Session.java:154) ... Logs from JSch: INFO: Connecting to xx.xx.xx.xxport 22 INFO: Connection established INFO: Remote version string: SSH-2.0-WeOnlyDo 2.0.6 INFO: Local version string: SSH-2.0-JSCH-0.1.44 INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128

The cipher 'aes256-cbc' is required, but it is not available

折月煮酒 提交于 2019-11-27 00:36:57
I am trying to do an SFTP using JSch, but I encountered some error: com.jcraft.jsch.JSchException: The cipher 'aes256-cbc' is required, but it is not available. Below is the code I used. Is there anything I missed out? JSch jsch = new JSch(); Session session = null; jsch.addIdentity("C:\\privatekey.ppk", "Password"); session = jsch.getSession("user", "54.251.240.234", 22); session.setConfig("StrictHostKeyChecking", "no"); Channel channel = session.openChannel("sftp"); channel.connect(); ChannelSftp sftpChannel = (ChannelSftp) channel; sftpChannel.put("C:\\Users\\test.txt", "/home/user/test.txt

Removing shell stuff (like prompts) from command output in JSch

随声附和 提交于 2019-11-26 23:33:53
问题 I have successfully SSH'ed into a node, sent the input, and retrieved the output. After inputting a line, the line is printed to the console, followed by a blank line, and then the output prints twice. I don't want the input to print to the console after it is entered, nor the blank line, nor the output printed a second time. Below is the code I have public void runSession() { try { Channel channel = session.openChannel("shell"); channel.setInputStream(System.in, true); channel

JSch logger - where can I configure the level

a 夏天 提交于 2019-11-26 23:17:19
问题 How can I configure the level of JSch logger? Is it like Log4J configurable via XML? 回答1: JSch doesn't seem to use any known logging framework (I use JSch v0.1.49, but the last version is v0.1.51), or any XML configuration file. So here is what I did: private class JSCHLogger implements com.jcraft.jsch.Logger { private Map<Integer, MyLevel> levels = new HashMap<Integer, MyLevel>(); private final MyLogger LOGGER; public JSCHLogger() { // Mapping between JSch levels and our own levels levels

Multiple commands through JSch shell

*爱你&永不变心* 提交于 2019-11-26 22:37:42
问题 I was trying to execute multiple commands through SSH protocol using the JSch library. But I seem to have stuck and cannot find any solution. The setCommand() method can only execute single commands per session. But I want to execute the commands sequentially just like the connectbot app on the Android platform. So far my code is: package com.example.ssh; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Properties; import