Re: [JSch-users] How to use JSch for the following scenario
Status: Alpha
Brought to you by:
ymnk
From: B. S. S. <sc...@sm...> - 2010-02-12 18:33:31
|
Yes. JSch jsch = *new* JSch(); Session session1 = jsch.getSession(username, "firewall", 22); session1.setUserInfo(*new* MyUserInfo(password1)); session1.connect(); session1.setPortForwardingL(8822, "machine", 22); Session session2 = jsch.getSession(username, "localhost", 8822); session2.setUserInfo(*new* MyUserInfo(password2)); session2.connect(); // Now execute all commands by creating channel on session2 Amol-Gmail wrote: > What it essentially means in code is the following? > > > JSch jsch = *new* JSch(); > Session session1 = jsch.getSession(username, "firewall", 22); > session1.setUserInfo(*new* MyUserInfo(password1)); > session1.connect(); > *int* assinged_port = session1.setPortForwardingL(8822, "machine", > 22); > Session session2 = jsch.getSession(username, "localhost", > assinged_port); // SHOULD IT BE assinged_port OR 8822 ???? > session2.setUserInfo(*new* MyUserInfo(password2)); > session2.connect(); > // Now execute all commands by creating channel on session2 > > Is this correct interpretation of your messages? > > > > ----- Original Message ----- > *From:* B. Scott Smith <mailto:sc...@sm...> > *To:* Amol-Gmail <mailto:am...@gm...> > *Cc:* jsc...@li... > <mailto:jsc...@li...> > *Sent:* Friday, February 12, 2010 10:20 PM > *Subject:* Re: [JSch-users] How to use JSch for the following scenario > > First, you can programmatically SSH to username@firewall > <mailto:username@firewall>. > Then, you can port forward local port 8822 to remote "machine:22". > Then you can programatically SSH to username@localhost:8822 > <mailto:username@localhost:8822>. > > Amol-Gmail wrote: >> Hi Team, >> >> I am using JSch module and have been successful in using it in >> most of the conditions. I am using standard way of connecting as >> provided in some of the examples which is working fine for me. >> >> Now I have an additional requirement, SSH is behind the firewall, >> and following is the manner in which user is connecting to it >> from his shell: >> >> >> ssh firewall@username <mailto:firewall@username> >> password: ******** >> ssh machine@username <mailto:machine@username> >> password *************** >> su - user >> password: ***** >> >> Once user fires this command, he can then fire any commands of >> interest in this session. I am wondering how to program this >> using JSch code in my java application. >> >> Any help/ideas are welcomed. >> >> >> Regards, >> Amol Kulkarni > |