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

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
Creating a new file in SSH enabled system using JSCH
How to interact with the script after its execution using Jsch
java jsch -executing multiple unix commands

Categories

HOME
vim
blogger
keycloak
isabelle
nullpointerexception
plot
octobercms
routes
google-docs
rsync
sqlite-net-extensions
analysis
rubygems
c#-2.0
jpeg
ezpublish
pivotal-cloud-foundry
echarts
convolution
python-unittest
metatrader4
handsontable
google-apps-marketplace
visual-studio-cordova
quickfix
django-admin
windows-7-x64
pugjs
aurigma
jprofiler
lldb
h2db
tdd
facebook-access-token
neo4j-spatial
compatibility
webkitspeechrecognition
skia
media-queries
binary-data
ecto
uisplitview
catel
calibre
windows-dev-center
textmate
xmlreader
cloud-code
sequential
picasso
dynamics-crm-2013
webix-treetable
sas-visual-analytics
mapzen
fedex
node-gyp
bootstrap-dialog
outlook-api
modelmapper
multipeer-connectivity
git-diff
font-size
jspdf-autotable
abcpdf9
azure-sdk
intrusion-detection
clang-static-analyzer
connect-by
skype4py
essence
pickadate
captivenetwork
photobucket
ios8-today-widget
maven-tomcat-plugin
lib.web.mvc
fouc
emailrelay
splash
dia
sorl-thumbnail
android-imagebutton
terminfo
responsive-slides
openexr
jubula
phpthumb
centos5
c18
ivyde
apc
flash-builder4.5
sharp-repository
flashvars
ocunit
clipper
browser-detection
qtkit
php-parser
tomcat-valve
javax.script
krl
xfbml
remember-me
yslow
blitz++
gallio
gamma
preference
dbal
audio-capture
port-number
putchar
w3wp
misv

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App