jsch

How can I specify the path of a JAR in an ant buildfile?

删除回忆录丶 提交于 2019-11-29 10:05:28
I am executing lot of scp and sshexec and other remote commands from an ant build script. These commands don't work if jsch.jar isn't in the ant lib directory. To make it work, I copied the JAR into the ant lib directory, but this is not a good solution, as anyone else wanting to run the script would have to do the same thing. To run the ant target from Teamcity, we will have to explicitly set the path of the lib file. Is there a way I can specify the path of the JAR in the ant build XML itself? Thanks all for your answers. I am managed to get it work with classloader task. This is what I did.

Jsch or SSHJ or Ganymed SSH-2?

限于喜欢 提交于 2019-11-29 09:58:19
问题 I need to connect to server(username,pasw,host)-- easy enter 3-10 commands -- command="dir;date;cd;dir" is there an easier way ?, without writing 20 lines: while(smtng) { a lot of stuff+ mysterious print to scr:D } download a file-- easy write another downloaded file to the same file (add not owerride) -- any ideas how? So to perform these increadible easy tasks, which might seem impossible if you dare to use Jsch(awsome documentation), there is a choise between Jsch,sshj,Ganymed any

JSch 0.1.53 session.connect() throws “End of IO Stream Read”

孤人 提交于 2019-11-29 09:42:14
I downloaded a new JSch 0.1.53 library and JSch (sftp) download task no longer works. This release fails on session.connect() function throwing an error Session.connect: java.io.IOException: End of IO Stream Read . My old jsch.jar(2011-10-06) works fine to the same host, maybe I am missing a new config props? Session session=null; ChannelSftp channel=null; try { JSch.setLogger(SSHUtil.createJschLogger()); JSch jsch=new JSch(); session=jsch.getSession("myuser", "11.22.33.44", 22); session.setConfig("StrictHostKeyChecking", "no"); session.setPassword("mypwd"); session.connect(2000); // <-- FAILS

Log stdout and stderr from ssh command in the same order it was created

99封情书 提交于 2019-11-29 08:48:56
Short Version: Is it possible to log the stdout and stderr on the local side of a command executed remotely via ssh in the same order as it was output on the remote host? If so, how? Long Version: I am attempting to log the standard and error output from a remotely exec'd SSH command (using Jsch) in the same order as it was output by the remote command. In other words, if the remote command writes "a" to stdout, then "b" to stderr, then "c" to stdout, I want the log on the client (local) side to read: a b c Below is what I have so far. It comes relatively close to what I want, but I think it

How to use jsch with ProxyCommands for portforwarding

两盒软妹~` 提交于 2019-11-29 08:43:43
I want to ssh to a machine which is behind a proxy and do a portforwarding after that in my java program. (To be able to ssh to the box I should have ssh'ed to the proxy machine first). I usually do that by having the following entries in my ~/.ssh/config file: ProxyCommand ssh proxyhost.com -t nc %h %p IdentityFile /home/username/username_dsa_key And then I run the following to do portforwarding to map hostmachine.com:54321 to my localhost:12345: ssh -A -L12345:localhost:54321 hostmachine.com Now I want to do these with Jsch library but I can't figure out how to connect to the second host

jsch ChannelExec run a .sh script with nohup “lose” some commands

强颜欢笑 提交于 2019-11-29 08:28:51
I hava a .sh script which glues many other scripts, called by jsch ChannelExec from a windows application. Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand("/foo/bar/foobar.sh"); channel.connect(); if I run the command like "nohup /foo/bar/foobar.sh >> /path/to/foo.log &", all the long term jobs(database operations, file processing etc.) seems to get lost. checking the log file, only find those echo stuffs(before and after a long term operation, calculate running time etc.). I checked the permissions, $PATH, add source /etc/profile to my .sh yet none of these

JSch getting “invalid privatekey:” while trying to load an RSA private key by KeyPairGenerator

馋奶兔 提交于 2019-11-29 07:37:24
I'm using java.security.KeyPairGenerator to gen an RSA key pair, and then try to load the private key via the KeyPair class provided in Jsch(0.1.49). The code: public static void main(String[] args) { String header = "-----BEGIN RSA PRIVATE KEY-----"; String footer = "-----END RSA PRIVATE KEY-----"; KeyPairGenerator keyPairGenerator; try { keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(2048, new SecureRandom()); PrivateKey privateKey = keyPairGenerator.genKeyPair().getPrivate(); String key = new String(Base64.encodeBase64(privateKey.getEncoded()));

Jenkins构建maven项目:找不到本地依赖JAR包的解决办法

筅森魡賤 提交于 2019-11-29 06:49:30
1. 依赖本地jar包: <dependency> <groupId>jsch</groupId> <artifactId>jsch</artifactId> <version>0.1.44</version> <scope>system</scope> <systemPath>${project.basedir}\src\main\webapp\WEB-INF\lib\jsch-0.1.44.jar</systemPath> </dependency> 2. 本地 用maven clean package打的war包里面有jar,放到Jenkins上打包就报错了。错误如下: Failed to execute goal on project ibisv3: Could not resolve dependencies for project *test:war:3.0: The following artifacts could not be resolved: jsch:jsch:jar:0.1.44, smshenan:smshenan:jar:1.0: Could not find artifact jsch:jsch:jar:0.1.44 at specified path /home/workspace/JR01_ktz_IBIS_tomcat_mysql_zh

Jsch error - failed to send channel request

£可爱£侵袭症+ 提交于 2019-11-29 06:40:41
I am trying to connect to a SFTP remote server using JSCH library version 0.1.49. Every time I run the program I receive the following error : Initializing... Connection to SFTP server is successfully com.jcraft.jsch.JSchException: Unable to connect to SFTP server.com.jcraft.jsch.JSchException: failed to send channel request at shell.MainClass.JschConnect(MainClass.java:95) at shell.MainClass.main(MainClass.java:30) line 30 is : sftpChannel.connect() from the code below : System.out.println("Initializing..."); JSch jsch = new JSch(); Session session = null; try { session = jsch.getSession

Keypair login to EC2 instance with JSch

◇◆丶佛笑我妖孽 提交于 2019-11-29 06:39:31
I want to be able to use the JSch Java SSH library to connect to my EC2 instance. How do I use my .pem keypair from AWS with JSch? How do I deal with the UnknownHostKey error when attempting to connect? The groovy code will use the JSch library to connect to an EC2 instance, run the whoami and hostname commands, then print the results to the console: @Grab(group='com.jcraft', module='jsch', version='0.1.49') import com.jcraft.jsch.* JSch jsch=new JSch(); jsch.addIdentity("/your path to your pem/gateway.pem"); jsch.setConfig("StrictHostKeyChecking", "no"); //enter your own EC2 instance IP here