jsch


com.jcraft.jsch.JSchException: Auth fail error


Trying to connect to a host using ssh key auth. Below is my code:
package com.mkyong.common;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
/**
*
*/
public class UserAuthPubKey {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
try {
JSch jsch = new JSch();
String user = "XXXXXXXX";
String host = "XXXXXXXX.XXXXXXX.com";
int port = 22;
String privateKey = "~/.ssh/WF_OPENSSH.ppk";
String passphrase = "XXXXXXXXXXX";
jsch.addIdentity(privateKey,passphrase);
System.out.println("identity added ");
Session session = jsch.getSession(user, host, port);
System.out.println("session created.");
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
System.out.println("session connected.....");
Channel channel = session.openChannel("sftp");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
System.out.println("shell channel connected....");
ChannelSftp c = (ChannelSftp) channel;
// String fileName = "test.txt";
// c.put(fileName, "./in/");
// c.exit();
// System.out.println("done");
} catch (Exception e) {
System.err.println(e);
}
}
}
what change should i make here. On debugging the error seems to occur at session.connect(); statement. I am using a private key and a passphrase to connect.
String privateKey = "~/.ssh/WF_OPENSSH.ppk";
Is that a PuTTY-format keyfile? Ie, was it generated from puttygen, the PuTTY key generation utility? Jsch only reads OpenSSH-format key files, not PuTTY-format files.
You can use puttygen to convert the key to OpenSSH format if you want to use that key. See this question.
Get the lastest version of JSch. The old version shows Auth Fail for no reason

Related Links

How to add timeout when use JSch to execute a shell command which need user input later
Decreased speeds when using JSch put compared to scp
JSCH Channel Is Not Opened (New)
What the situation will make channel.getExitStatus() return 1
JSch read local log file
JSCH setCommand is not working
com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 No appropriate prime between 1024 and 1024 is available. en
I'm trying to use Jsch to establish an SSH connection in Java.I got the Exception com.jcraft.jsch.jschexception unknownhostkey
com.jcraft.jsch.JSchException: failed to send sftp request
JSch for pbrun not working
JSCH read from input stream hangs from time to time
Hundreds of Apache SSHD clients leave hundreds of OpenSSH daemon processes running
Jsch - ssh connection through ssh tunnel
Changing password using Jsch and ChannelExec
how to delete local file using jsch after file is sent to remote SFTP server directory
com.jcraft.jsch.JSchException: Auth fail error

Categories

HOME
winforms
wso2-am
keras
openstack
urbancode
reserved
include
leon
infragistics
malloc
rubygems
azure-media-services
android-youtube-api
facebook-messenger-bot
tomcat6
kentor-authservices
quicklook
phaser
zebra-printers
designer
try-catch
workload-scheduler
libtiff
nhibernate-envers
django-cms
google-pagespeed
visual-composer
visjs
scriptcs
cloudhub
dcevm
qhull
cas
selectedindexchanged
wpfdatagrid
buck
unboundid
twilio-api
semantic-versioning
ioio
usbserial
uiswipegesturerecognizer
accelerate-framework
ghost4j
android-ble
serve
qwerty
scaffold
greenrobot-eventbus
mesos-chronos
arena-simulation
businessworks
auto-update
network-flow
logparser
ionicons
hls.js
carrot
ableton-live
angular-cache
database-optimization
pcf
skype4py
bgp
xpath-1.0
jms2
google-places
django-unittest
ionic
myo
event-bubbling
oberon
apache-commons-net
umbraco6
system.reflection
jscript.net
gui-test-framework
markers
xojo
android-radiobutton
heisenbug
dml
transcoding
farseer
web2py-modules
seed
ember-app-kit
robotics-studio
sublist
venn-diagram
ohm
qt-jambi
data-loss
spyware
gcj
mod-auth
recent-documents
routedevent
exchange-server-2003
backcolor
mediarss
genealogy
3gp
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App