Re: [JSch-users] ssh over ssh using JSCH

2013-01-15 Thread Chinmay Shepal
Thank you for your quick response.

I could solve the issue using the examples provided by jsch team!!


On Sun, Jan 13, 2013 at 2:07 AM, Paul Ebermann
paul.eberm...@esperanto.dewrote:

 Chinmay Shepal skribis: Hi,
 
  Recently I have started using jsch.
 
  Our setup here is like my server resides behind gateway.
  So first I need to do ssh to gateway and from there I
  need to ssh to my server. I am using following code.

 I did not examine your code, but I did something like this some time
 ago, using a custom Proxy implementation.

 http://sourceforge.net/apps/mediawiki/jsch/index.php?title=ProxySSH


 PaĆ­lo




-- 
Thanks,
Chinmay Shepal
--
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512___
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users


[JSch-users] ssh over ssh using JSCH

2013-01-08 Thread Chinmay Shepal
Hi,

Recently I have started using jsch.

Our setup here is like my server resides behind gateway. So first I need to
do ssh to gateway and from there I need to ssh to my server. I am using
following code.

package testPack;

import java.io.InputStream;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class sshExample {
public static void main(String[] args) {
String host=xx.xx.xx.xx;
String user=user;
String password=password;
String command1=ssh tom...@yy.yy.yy.yy;
try{
java.util.Properties config = new java.util.Properties();
config.put(StrictHostKeyChecking, no);
JSch jsch = new JSch();
Session session=jsch.getSession(user, host, 22);
session.setPassword(password);
session.setConfig(config);
session.connect();
System.out.println(Connected);
Channel channel=session.openChannel(exec);
((ChannelExec)channel).setCommand(command1);
channel.setInputStream(null);
((ChannelExec)channel).setErrStream(System.err);
InputStream in=channel.getInputStream();
channel.connect();
byte[] tmp=new byte[1024];
while(true){
  while(in.available()0){
int i=in.read(tmp, 0, 1024);
if(i0)break;
System.out.print(new String(tmp, 0, i));
  }
  if(channel.isClosed()){
System.out.println(exit-status: +channel.getExitStatus());
break;
  }
  try{Thread.sleep(1000);}catch(Exception ee){}
}
channel.disconnect();
session.disconnect();
System.out.println(DONE);
}catch(Exception e){
e.printStackTrace();
}
}

}

I am getting following error message :
Connected
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-with-mic,password).
exit-status: 255
DONE

Can you please help me on this?

-- 
Thanks,
Chinmay Shepal
--
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 ___
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users