Hi All,
I am trying to implement SFTP using JSch classes to download files
from one Unix system to another Unix system.
I am encountering java.lang.NullPointerException in the
Session.connect() method. Not sure what am I doing wrong. Following is
my SFTP code:
Session sftpSession = null;
try {
JSch jsChannel = new JSch();
jsChannel.setKnownHosts("/home/vchander/.ssh/known_hosts");
//Enter the Username and Host name
sftpSession = jsChannel.getSession("tbabu",
"ios0483e.idc.ikonic.org",22);
//Enter the user password
sftpSession.setPassword("black123");
try{
sftpSession.connect();
} catch(Exception e){
System.out.println(e.getMessage());return e.toString() +" ... " +
e.getLocalizedMessage() ; }
Same exception is thrown for following code also:
Session sftpSession = null;
try {
JSch jsChannel = new JSch();
String str1="ios0483e.idc.ikonic.org,10.11.52.134 ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAIEAt6QfRQM8RuFEbQ9nJ/UUYt3EWD2Apqwuyb/kqsX3gazqPz5FKD/z7MkyIVZ208M2q223tp7J7z4tKmDTd7XeAsoreacBLHdWCvN3JMB6AEuI6CbkGmOoovoRpV+/3nmmSH1vXn89qGjqrhG8cSDLU/gL7fqVpTr+Xhn4OAYLc9E=";
InputStream bas = new ByteArrayInputStream(str1.getBytes());
jsChannel.setKnownHosts(bas);
//Enter the Username and Host name
sftpSession = jsChannel.getSession("tbabu", "ios0483e.idc.ikon.org",22);
//Enter the user password
sftpSession.setPassword("black123");
try{
sftpSession.connect();
} catch(Exception e){ System.out.println(e.getMessage());return
e.toString() +" ... " + e.getLocalizedMessage() ; }
But using the same code from Windows system to download Unix files it
works fine. Not sure if I am missing any configurations.
Any help would be highly appreciated!
Thanks in Advance,
Uday
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users