Questions tagged [jsch]

JSch is a pure Java implementation of SSH2. JSch allows you to connect to an SSH server and use port forwarding, X11 forwarding, file transfer, etc., and you can integrate its functionality into your own Java programs.

JSch is a pure Java implementation of SSH2. JSch allows you to connect to an SSH server and use port forwarding, X11 forwarding, file transfer, etc., and you can integrate its functionality into your own Java programs.

Why JSch?

Originally, our motivation to develop this stuff is to allow users of our pure java X servers, WiredX, to enjoy secure X sessions. So, our efforts had mostly targeted to implement the SSH2 protocol for X11 forwarding. Of course, however, we are now also interested in adding other functionality like port forward, file transfer, terminal emulation, etc.

Features:

  • JSch is in pure Java, but it depends on Java Cryptography Extension (JCE). JSch is know to work with:
  • SSH2 protocol support.
  • Key exchange: diffie-hellman-group-exchange-sha1, diffie-hellman-group1-sha1
  • Cipher: blowfish-cbc, 3des-cbc, aes128-cbc, aes192-cbc, aes256-cbc, aes128-ctr, aes192-ctr, aes256-ctr, 3des-ctr, arcfour, arcfour128, arcfour256
  • MAC: hmac-md5, hmac-sha1, hmac-md5-96, hmac-sha1-96
  • Host key type: ssh-dss, ssh-rsa
  • Userauth: password
  • Userauth: publickey (DSA, RSA)
  • Userauth: keyboard-interactive
  • Userauth: gss-api-with-mic
  • X11 forwarding
  • xauth spoofing
  • connection through HTTP proxy.
  • connection through SOCKS5 proxy.
  • port forwarding.
  • stream forwarding.
  • signal sending.
  • environment variable passing.
  • remote exec.
  • generating DSA and RSA key pairs.
  • changing the passphrase for a private key.
  • partial authentication
  • SSH File Transfer Protocol(version 0, 1, 2, 3)
  • packet compression: zlib, zlib@openssh.com JZlib has been used.
  • hashed known_hosts file.
  • NONE Cipher switching. High Performance Enabled SSH/SCP supports NONE Cipher switching. Refer to ScpToNoneCipher.java.
  • JSch is licensed under BSD style license.

Official Website: http://www.jcraft.com/jsch/

Useful Links:

1673 questions
209
votes
13 answers

com.jcraft.jsch.JSchException: UnknownHostKey

I'm trying to use Jsch to establish an SSH connection in Java. My code produces the following exception: com.jcraft.jsch.JSchException: UnknownHostKey: mywebsite.example. RSA key fingerprint is 22:fb:ee:fe:18:cd:aa:9a:9c:78:89:9f:b4:78:75:b4 I…
Alex
  • 16,409
  • 6
  • 40
  • 56
129
votes
12 answers

"Invalid privatekey" when using JSch

I'm using the following code to work with Git in a Java application. I have a valid key (use it all the time), and this specific code has work for me before with the same key and git repository, but now I get the following exception: invalid…
o_b7
  • 1,357
  • 2
  • 10
  • 7
86
votes
15 answers

scp transfer via java

What is the best method of performing an scp transfer via the Java programming language? It seems I may be able to perform this via JSSE, JSch or the bouncy castle java libraries. None of these solutions seem to have an easy answer.
Lloyd Meinholz
  • 2,580
  • 1
  • 22
  • 20
67
votes
9 answers

Run a command over SSH with JSch

I'm trying to run a command over SSH with JSch, but JSch has virtually no documentation and the examples I've found are terrible. For example, this one doesn't show code for handling the output stream. And, this one uses an ugly hack to know when to…
jshen
  • 11,507
  • 7
  • 37
  • 59
60
votes
1 answer

Can we use JSch for SSH key-based communication?

I am using JSch for sftp communication, now i want to use facilitate the key-based authentication, key is loaded on client and server machine once by my network team and all later communication would be only user based for which we have loaded the…
Ahmad Nadeem
  • 2,056
  • 1
  • 18
  • 19
54
votes
6 answers

Connect to remote MySQL database through SSH using Java

How can I connect to remote MySQL database through SSH from java application? Small code example is helpful for me and I'd appreciate this.
Alex
  • 16,409
  • 6
  • 40
  • 56
50
votes
4 answers

SFTP connection through Java asking for weird authentication

So I'm writing a little program that needs to connect to a remote server through SFTP, pull down a file, and then processes the file. I came across JSch through some answers here and it looked perfect for the task. So far, easy to use and I've got…
cardician
  • 2,451
  • 3
  • 26
  • 36
48
votes
3 answers

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

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…
bittersour
  • 937
  • 2
  • 11
  • 32
46
votes
12 answers

JSchException: Algorithm negotiation fail

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…
Marek Dominiak
  • 693
  • 1
  • 7
  • 9
40
votes
10 answers

Algorithm negotiation fail SSH in Jenkins

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…
sarbo
  • 1,661
  • 6
  • 21
  • 26
39
votes
4 answers

SSH using jschexception verify false sometimes fails

The requirement is to ssh from one server to multiple server and execute a command. When I do this I frequently, but not always, receive this exception when trying to ssh from one server to another. What could be the reason for this and how can it…
dinesh kumar
  • 391
  • 1
  • 3
  • 5
36
votes
2 answers

Connecting to Mongo database through SSH tunnel in Java

FIXED (edited code to reflect changes I made) I'm trying to connect to a Mongo database through an SSH tunnel using Java. I'm using the Mongo driver 3.0.2 and jcraft (JSch) to create an SSH tunnel. The idea is that I: connect to the machine hosting…
David V
  • 360
  • 3
  • 6
36
votes
6 answers

How do I run SSH commands on remote system using Java?

I am new to this kind of Java application and looking for some sample code on how to connect to a remote server using SSH , execute commands, and get output back using Java as programming language.
sweety
  • 359
  • 1
  • 3
  • 5
35
votes
9 answers

"com.jcraft.jsch.JSchException: Auth fail" with working passwords

While trying to upload the file to our server, i am getting the following exception com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:464) at…
vinay
  • 1,366
  • 1
  • 13
  • 23
31
votes
4 answers

What is the difference between the 'shell' channel and the 'exec' channel in JSch

I want to be able to send many consecutive command represented as strings within a Java application to a SSH server for execution. Should I use: Channel channel = session.openChannel("shell"); -or- Channel channel = session.openChannel("exec");
Martin Klosi
  • 3,098
  • 4
  • 32
  • 39
1
2 3
99 100