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
Filter by
Sorted by
Tagged with
7 votes
2 answers
5k views

Using private RSA Key from .keystore File with Jsch

I am trying to get private Key from a .keystore File that I created. So far, this is working: try { FileInputStream is = new FileInputStream("C:\\Program Files\\Java\\...mykeystore....
ArBei's user avatar
  • 105
7 votes
3 answers
13k views

Using SSH authentication with JGit to Access a Git Repository Securely / Auth fail

I'm using JGit in scala to access a remote Git repo, and I need to use SSH for authentication. JGit uses JSch to provide secure access. I followed this tutorial : http://www.codeaffine.com/2014/12/09/...
Houssem Ben Slama's user avatar
7 votes
1 answer
5k views

How to remove ANSI control chars (VT100) from a Java String

I am working with automation and using Jsch to connect to remote boxes and automate some tasks. I am having problem parsing the command results because sometimes they come with ANSI Control chars. I'...
Leo's user avatar
  • 6,530
7 votes
1 answer
3k views

JSch multiple tunnels/jumphosts

I'm not sure if this is caused by using a private key instead of password for the port forwarding but here's what I'm trying to do I need to forward local port 3308 all the way to the my SQL DB at ...
Fangming's user avatar
  • 25k
7 votes
1 answer
5k views

How can I convert PEM file to string for ssh to ec2 using JSch library

I am trying to SSH to EC2 using JSch Library from Java code. I referred this link in SO How can I use .pem files content as a string in ec2 connection using JSch library and tried couple of things as ...
Dwarrior's user avatar
  • 737
7 votes
2 answers
17k views

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

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) ...
user627110's user avatar
7 votes
1 answer
8k views

Loading private key from string or resource in Java JSch in Android app

I'm writing an app which is supposed to access my private server via SSH using JSch. Since I have set up public key authentication I want this app to authenticate the same way. I will be the only one ...
tai's user avatar
  • 498
7 votes
1 answer
2k views

"tail -f" process will not exit after JSch connection closed

I used JSch to tail a file in remote computer. But I found that after the program exit, the "tail -f" process is still there in remote computer. if I remove the "-f" param, everything is OK. I've ...
wangke1020's user avatar
6 votes
4 answers
25k views

JSCH: SFTP. Hangs at session.connect() using the port 21

I am connecting to FTP server via sftp(JSCH). Evertime i connect to the FTP server using the port 21, it always hangs at session.connect(). It does not throw any exception. But when i use other ...
aeycee's user avatar
  • 167
6 votes
3 answers
30k views

Transfer folder and subfolders using ChannelSftp in JSch?

I want to transfer a folder and a subfolder using JSch ChannelSftp. I can successfully transfer files using channelsftp.put(src, dest) command but this does not work for folders (at least I could not ...
waqas's user avatar
  • 1,125
6 votes
3 answers
7k views

Teamcity SSH private key login failed: invalid privatekey

I set SSH login which connect from Windows Agent to Linux but TeamCity gives following error. [New build problem] com.jcraft.jsch.JSchException: invalid privatekey: [B@5543cd The keypair which ...
Youngjae's user avatar
  • 24.7k
6 votes
1 answer
3k views

Use Jsch with InputStream is throwing NullPointerException [duplicate]

I'm trying to send a file using JSCH over SFTP protocol. Here is the FileService file public class FileService { public void send(){ String str = "this is a test"; ...
Renato Ramos Nascimento's user avatar
6 votes
1 answer
10k views

JSch: UnknownHostKey exception even when the hostkey fingerprint is present in the known_hosts file

There are two questions about this exception already: JSchException: UnknownHostKey and com.jcraft.jsch.JSchException: UnknownHostKey I am using a Windows machine and trying to connect to a VM ...
gary69's user avatar
  • 3,992
6 votes
1 answer
12k views

.JSchException: Packet corrupt

I am using Jsch 0.1.51 on RHEl 6 with Jdk 1.7_51. While making session to a remote machine I am getting exception that is : com.jcraft.jsch.JSchException: Packet corrupt at com.jcraft.jsch....
Chandan Gupta's user avatar
6 votes
1 answer
5k views

What are the key file formats of JSch and sharpSSH?

I'm looking at setting up public key client and server authentication for SFTP using the JSch library (or actually the sharpSSH C# port of it). Unfortunately I cannot find any documentation for the ...
Patrick's user avatar
  • 8,251
6 votes
1 answer
4k views

JSch get() fails with NullPointerException

I've got a Jax-RS server which is supposed to keep a list of files accessible via ssh that I can then download or stream via HTTP. I've been trying to read the files with JSch's SFTP channel, but I ...
KG6ZVP's user avatar
  • 3,629
6 votes
2 answers
8k views

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

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 (...
Jacob Schwartz's user avatar
6 votes
2 answers
11k views

can I re-add remote host to known_host using JSCH?

I want to be able to remove the remote server key from known_hosts and add it again. The remote server gets updated often so I want to automatically remove the remote host key and add its new key to ...
Aboutblank's user avatar
6 votes
1 answer
6k views

Jsch How to reuse a session

I am creating many different (Session) objects passing the login credentials to a java class from an Oracle pl/sql package. I then store this (Session) objects in a Vector. The idea is to connect, ...
Luca's user avatar
  • 81
6 votes
2 answers
5k views

Get Public DNS of Amazon EC2 Instance from JAVA API

I have managed to start, stop and check the status of a previously created EC2 instance from JAVA API. However, i'm having difficulty on getting the public dns address of this instance. Since I start ...
jatha's user avatar
  • 934
6 votes
1 answer
15k views

SFTP path format versus local path format

I'm writing some Java code (using JSch library) to SFTP into a remote Windows machine and copy a file to my local Windows folder. When specifying the path to the file on the remote machine, I'm ...
plz_do_the_needful's user avatar
6 votes
5 answers
13k views

sftp fails with 'message too long' error

My java program uses ssh/sftp for transferring files into linux machines (obviously...), and my library for doing so is JSch (though it's not to blame). Now, some of these linux machines, have shell ...
tomper's user avatar
  • 737
6 votes
1 answer
3k views

Putting Jsch into connection pool in details

I put Jsch into commons-pool (with spring pool support) with initial success http://docs.spring.io/spring/docs/3.2.4.RELEASE/spring-framework-reference/htmlsingle/#aop-ts-pool However: Should we ...
simonso's user avatar
  • 595
6 votes
4 answers
14k views

"JSchException: reject HostKey" when connecting to SSH server from Java using JSch

I try to establish a connection with MySQL base in PythonAnywhere using SSH in my Java program according to instruction: https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere ...
Szejder's user avatar
  • 87
6 votes
1 answer
12k views

"reject HostKey" when connecting to remote host through jumphost with JSch

Need to SSH to destination host through jumphost. Had tried the same mentioned in JSch JumpHosts example. Session[] sessions = new Session[2]; Session session = null; sessions[0] = session = jsch....
Rajar R's user avatar
  • 127
6 votes
1 answer
11k views

Trying to connect to postgres database with jsch and jdbc yields "The connection attempt failed. Caused by: java.io.EOFException"

I'm trying to connect to a postgres database running on an Amazon EC2 server. I know that the server is configured properly as I can access it from pgadmin and as a data source within intellij. I ...
Yash Sharma's user avatar
6 votes
1 answer
2k views

Jsch with spongycastle rather than bouncycastle on Android

I currently have an Android application connecting to my router via ssh using a password. I'm looking to improve this so I can use keys but I am having real issues. From what I understand the version ...
Fuzzy's user avatar
  • 844
6 votes
1 answer
1k views

Encrypting large file with PGP (BouncyGPG) and sending it over SFTP (JSch) in Kotlin

I've been trying to encrypt large files with PGP (I'm using BouncyGPG for that) and sending it to a remote server using SFTP (using JSch). I'm using PipedOutputStream and PipedInputStream to avoid ...
ademarizu's user avatar
  • 865
6 votes
0 answers
12k views

Failure error in JSch while uploading file to a sftp (Private key auth) [closed]

I'm trying to upload a file to a sftp server using JSch libs after private key authentication. But put,mkdir etc actions are throwing failure messages. I tried several ways, sure it looks like a ...
Raghu's user avatar
  • 722
5 votes
4 answers
60k views

How to get list of files from an SFTP server?

I have a problem and hoping to get a solution. I also have written some code but it needs some modification. Problem: I have a SFTP server (for privacy purposes I will give dummy credentials) that I ...
SupaHotFire's user avatar
5 votes
4 answers
35k views

Finding file size and last modified of SFTP oldest file using Java

I'm using JSch to get files from an SFTP server, but I'm trying to figure out a way to only get the oldest file, and to make sure that it is not currently being written to. The way I imagine myself ...
ryantmer's user avatar
  • 673
5 votes
6 answers
26k views

Jsch - One Session Multiple Channels

I managed to execute a single command through ssh with Jsch but when i try to execute a second command it fails For debugging i brought this problem down to this lines: import java.io.IOException; ...
Nick Russler's user avatar
  • 4,638
5 votes
4 answers
14k views

Set Directory Permissions CHMOD with JSCH

In Unix, how do I set the directory permissions with JSCH? I am looking to do drwxrwxrwx. Filezilla says the integer for that is 775 but JSCH is not setting the permissions correctly. After JSCH ...
Greg Finzer's user avatar
  • 6,834
5 votes
1 answer
5k views

Explanation for SCP protocol implementation in JSch library

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. ...
MiamiBeach's user avatar
  • 3,311
5 votes
4 answers
11k views

What is the reason to get exit status value -1 in JSch

I am trying to run a command on a remote Linux box from Java using JSch (SSH) API. The value of exitStatus is -1 i.e. int exitStatus = channelExec.getExitStatus() What is the possible reason to get a ...
Saikat's user avatar
  • 15.6k
5 votes
1 answer
5k views

Move a directory in remote server to another location in the same remote server using jsch

I am using JSCH API to connect to remote server through sftp. I need to move a directory present in the remote server from location A to location B. It looks like the method channelsftp.put(src,dest) ...
Michael Maze's user avatar
5 votes
2 answers
25k views

Downloading Multiple Files via SFTP using Java

I am new to java and I am trying to write a script that will pull multiple files from various SFTP sites daily. I have code below that will pull 1 file from 1 site and it works, however I am ...
tollgen's user avatar
  • 209
5 votes
2 answers
13k views

JSCH addIdentity public key argument doesn't make a difference

public class FTP { public static void main(String args[]){ JSch jsch = new JSch(); jsch.setKnownHosts("./known_hosts"); Path privateKeyPath = Paths.get("./id_dsa"); byte[] ...
Kam's user avatar
  • 5,928
5 votes
3 answers
60k views

com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect

I understand that there is duplicate >>> copied from the duplicate >>>As long as your local machine has an SSH server running <<<<< but i cannot comment and cannot as from the question (...
Kelly's user avatar
  • 143
5 votes
2 answers
31k views

Running Linux commands on Java through JSch

I'm establishing an SSH connection through JSch on Java and everything seemed to be working fine, until I tried to run this .sh file. The shell script's name is repoUpdate.sh and it's very simple: ...
Miguel Ángel's user avatar
5 votes
2 answers
20k views

How to perform multiple operations with JSch

I am new to SSH and JSch. When I connect from my client to the server I want to do two tasks: Upload a file (using ChannelSFTP) Perform commands, like creating a directory, and searching through a ...
user avatar
5 votes
2 answers
5k views

To run sudo commands on a ec2 instance

I cannot run "sudo su" on my ec2 client , I ssh into the client through a java program and run the command through a program. I can run commands like "ls" and "ifconfig" though. I get an error saying ...
Jaimin Shah's user avatar
5 votes
1 answer
9k views

How to tell if an SFTP upload was successful using JSch

Unfortunately the getExitStatus() method always returns -1 so i can't use that to tell me whether or not a file upload worked. I tried to use the getInputStream() method of the Channel class but ...
rage's user avatar
  • 1,797
5 votes
4 answers
10k views

Creating nested directories on server using JSch in Java

I am making an application for file uploading in Java using jSch. I want to put my file in different directories based on their creation date etc. I have a main directory "/var/local/recordingsbackup/...
earthmover's user avatar
  • 4,425
5 votes
2 answers
13k views

Jsch renaming file fails

I am uploading a large file by SFTP over Jsch. During the upload process, the old file should be available, so I'm uploading to a temp file and rename it to the new file. final String tmpName = dest ...
Stephan's user avatar
  • 4,425
5 votes
3 answers
3k views

Limit the output of jsch in Spring integration

I am trying to limit the output of the com.jcraft.jsch package in my Spring Boot applicatoin. My application uses Spring Intgration and has a log4j.properties files defining the following log levels #...
Jes Chergui's user avatar
  • 1,318
5 votes
1 answer
5k views

What is the difference between exit and quit in jsch's ChannelSftp?

I'm currently developing a program with jsch, and I am looking at the ChannelSftp class. I just want to know the difference between the quit and exit method. In the help string of the Sftp example it ...
ides's user avatar
  • 369
5 votes
2 answers
50k views

JSchException timeout: socket is not established

I am trying to use JSch to connect to my computer through ssh and then run a command. However, when I run the code I never connect to the computer. and the following error: I/System.out: com....
kalenpw's user avatar
  • 695
5 votes
1 answer
9k views

Connecting to remote Windows machine with JSch

I want to execute command on remote system and want to get result of the same. I tried following code: package rough; import java.io.InputStream; import com.jcraft.jsch.Channel; import com.jcraft.jsch....
Aditya's user avatar
  • 858
5 votes
1 answer
4k views

JSch: Checking a private key file passphrase before trying to connect

For quite a simple application that mostly depends on ssh connections made via JSch, I wanted to ask for the passphrase at the login screen, try to decrypt the private key and if it is wrong, go back ...
Raúl Salinas-Monteagudo's user avatar

1 2
3
4 5
34