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
18
votes
4 answers

Accessing a git repository via ssh behind a firewall

I would like to access (clone/push/pull) a private (via ssh) git repository while behind a corporate firewall that only allows http proxy access. I have written a robust Java (daemon) program (based on the JSCh class library) that will allow me to…
pajato0
  • 3,628
  • 3
  • 31
  • 37
18
votes
3 answers

Downloading files from an SFTP server using JSch

I am using jsch to download files from server, my code below. public static void downloadFile(TpcCredentialsDTO dto) { logger.trace("Entering downloadFile() method"); Session session = null; Channel channel = null; …
FaithN
  • 213
  • 1
  • 3
  • 7
18
votes
6 answers

Using JSch, is there a way to tell if a remote file exists without doing an ls?

Using JSch, is there a way to tell if a remote file exists without doing an ls and looping through the files to find a name match? Thanks
cagcowboy
  • 30,012
  • 11
  • 69
  • 93
17
votes
1 answer

Specifying SSH key for JGit

I'm wondering how I can use jgit to connect to github using a specified ssh key file (i.e. one not in ~/.ssh/). Unfortunately, I'm not sure how to use JschConfigSessionFactory properly. I've tried creating a setup just like the one in this article:…
nstbayless
  • 175
  • 1
  • 1
  • 7
17
votes
5 answers

JSCH - Invalid private key

I am running JDK 1.7 & Windows 7 using netbeans 7.2 I have generated a SSH private & public key pair (SSH2-2048 bits) using putty-keygen. I do not have any password for private key. I am now trying to connect to one of the host machine using SFTP.…
17
votes
3 answers

Using Keys with JGit to Access a Git Repository Securely

I'm using JGit to access a remote Git repo, and I need to use SSH for it. JGit uses JSch to provide secure access. However, I'm not sure how to set the key file and the knows hosts file for JGit. What I have tried is as follows. Created a custom…
Izza
  • 2,389
  • 8
  • 38
  • 60
16
votes
1 answer

com.jcraft.jsch.JSchException: channel is not opened when opening a channel in jsch

When connecting to a remote host using jsch version 0.1.51 we occasionally run into the following exception when calling Channel.connect() on a ChannelExec. com.jcraft.jsch.JSchException: channel is not opened. at…
K Erlandsson
  • 13,408
  • 6
  • 51
  • 67
15
votes
1 answer

JSch SFTP upload/download progress

I am new to JSch and Java. I managed to get some code and understand it somehow, but I am stuck on one point. The following code downloads file from SSH/SFTP server, but I am in need of the progress meter that shows percentage of file copied. How…
World
  • 2,007
  • 7
  • 27
  • 37
15
votes
3 answers

How to Set Root Directory in Apache Mina Sshd Server in Java

I use Apache Mina Sshd API to start up a local SFTP server in java.In SFTP client i use Jcraft jsch API to create my SFTP client.I successfully start up a server.The problem is that i want to write some unit test cases to check whether client can…
gihan-maduranga
  • 4,381
  • 5
  • 41
  • 74
14
votes
2 answers

JSch logger - where can I configure the level

How can I configure the level of JSch logger? Is it like Log4J configurable via XML?
Alexey
  • 179
  • 1
  • 2
  • 10
14
votes
3 answers

How to get jsch shell command output in String

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…
vishy
  • 483
  • 2
  • 7
  • 16
14
votes
2 answers

How to use Java JSch library to read remote file line by line?

I am trying to use Java to read a file line by line, which is very simple (there are multiple solutions for this on stackoverflow.com), but the caveat here is that the file is located on a remote server, and it is not possible to get a local copy…
user3898238
  • 957
  • 3
  • 11
  • 25
14
votes
2 answers

What is use of config.put("StrictHostKeyChecking", "no") in JSch

java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); In above code why we need to set StrictHostKeyChecking value as no while connection to SFTP through JSch…
king Ramesh
  • 141
  • 1
  • 1
  • 3
14
votes
2 answers

Why does an SFTP connection still exist after the JSCH Channel has been closed?

When the code below has finished running, netstat -a|grep sftp shows an open SFTP connection. It also shows up as an open connection in JProfiler. channel.isConnected() in the finally block prints false. Any ideas why the connections is not being…
Michael
  • 13,838
  • 18
  • 52
  • 81
13
votes
2 answers

How can I access an FTP server with JSch?

I installed FileZilla FTP Server on my local Windows 7 machine. I also installed FileZilla FTP client on the same machine. Connection is successfull between both of them confirming the server and client partnership exists. I wrote a small quick and…
Kedar Pulaparthi
  • 131
  • 1
  • 1
  • 3