LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-09-2013, 06:56 AM   #1
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Rep: Reputation: 4
program to listen on TCP socket and start some program with I/O redirected to socket


Hi. Is there a progam that does this? I need it to traverse ssh server with tunnels disabled.

Last edited by leniviy; 08-09-2013 at 08:06 AM.
 
Old 08-09-2013, 11:19 AM   #2
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Yes.
It is called xinetd

But could explain a little more what you try to do, so we can explain a little better how to do it.

Cheers
 
Old 08-10-2013, 04:10 AM   #3
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
There's a jumpstation to a closed network. I'm supposed to login to this JS with ssh and run another ssh command to connect to the target server. SSH tunnels on JS are disabled for security reasons.

I want to run a GUI database client.

The JS has modern bash which supports IO redirection to /dev/tcp/host/port.

On My workstation, when the database client connects to xinetd, it would launch ssh with remote command like this:
Code:
"exec 4<>/dev/tcp/serv1/1521 && cat >&4 <&0 & cat <&4"
 
Old 08-12-2013, 05:47 AM   #4
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
My Solution:
Code:
         localhost                               jumpstation                            srv
 ----------------------------           ----------------------------------        ----------------
|                            |         |                                  |      |                |
|   ----------------------   |         |                                  |      |                |
|  | Oracle SQL Developer |  |         |   ----------------------------   |      |                |
|   ----------------------   |         |  |  exec 4<>/dev/tcp/srv/1521 |  |      |                |
|            |               |         |  |                            |  |      |                |
|        ----------          |         |  |       ->-- "cat >&4"       |  |      |    --------    |
|       | wininetd |         |   |-----|--|------|                     |--|------|---| Oracle |   |
|        ----------          |   |     |  |       -<-- "cat <&4"       |  |      |    --------    |
|            |               |   |     |   ----------------------------   |      |                |
|         -------            |   |     |                                  |      |                |
|        | plink |-----------|---      |                                  |      |                |
|         -------            |         |                                  |      |                |
|                            |         |                                  |      |                |
 ----------------------------           ----------------------------------        ----------------
Wininetd was modified to work correctly with plink.
plink's stderr is redirected to nul.
Remote ssh command:
Code:
exec 4<>/dev/tcp/%host%/%port% || exit 1; cat <&4 & exec 1>&-; cat >&4 <&0; exec 0<&-; sleep 10; kill $!
 
Old 08-12-2013, 05:51 AM   #5
leniviy
Member
 
Registered: Jul 2009
Distribution: Archlinux
Posts: 69

Original Poster
Rep: Reputation: 4
Since there's no way to call shutdown() on the socket opened by bash, I have to close all inherited fds of the socket. I do it by killing the receiving "cat".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I prevent a socket from being redirected? Mans Programming 3 04-15-2013 01:35 AM
Client Server Socket TCP/IP program in C Linux over HTTPS fahad.anwar Linux - Newbie 6 05-29-2012 03:59 AM
Client Server Socket TCP/IP program in C Linux using threads fahad.anwar Linux - Newbie 2 05-18-2012 04:34 AM
Socket program doubt Gwapala Linux - Networking 1 07-22-2010 02:37 PM
socket program in kernel mathimca05 Linux - Kernel 1 01-21-2008 06:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration