Piped output from SSH tunnel hangs?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Piped output from SSH tunnel hangs?
# 1  
Old 04-13-2011
Piped output from SSH tunnel hangs?

Hi All,

When starting an SSH tunnel, piped output 'hangs' (on AIX) :
Code:
ssh -Nf -Llocalhost:22000:server:22 proxy | cat -vet -
... hangs ...

Does anybody know how to prevent this?

Of course, in my script I don't use the tunnel as I do in the example above. In my script the call to ssh is part of a function that does some checks. It's the output of those checks that I want to pipe to a logging function, something like :
Code:
function start_tcp_tunnel
  pre checks...
  ssh -Nf -Llocalhost:22000:server:22 proxy
  post checks...
}

function log {
  while read line ; do
    echo $(date) $line
  done
}

start_tcp_tunnel | log

Regards,
Willem.
# 2  
Old 04-15-2011
The tunnel in ssh is a side-effect that should not change what ssh does without a tunnel. Other apps use the tunnel to get secure access between hosts. cat - hangs because you supply no input to ssh, tunnel or no. How is the tunnel working?
# 3  
Old 04-15-2011
Thanks for your response. As I understand, the option '-N' makes it that ssh doesn't expect input. From the man page :

-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).

In my script, I first use `ssh -Nf -Llocalhost:22000:server:22 proxy` to create the tunnel, then it executes sftp to upload files.

Regards,
Willem.
# 4  
Old 04-15-2011
Well, sftp is secure, and needs no tunnel. Plain ftp will not tunnel, it is a multi-connection, address and port passing, old protocol. Unless you are addicted to old things, just scp and forget the tunnel.
# 5  
Old 04-15-2011
I can't sftp/scp to the target server directly, it needs to go through 'proxy'
# 6  
Old 04-15-2011
sftp and scp are ssh under the covers, so how do you get a tunnel? Oh, I see, the tunnel is on the proxy. It is a bit tragic to ssh inside ssh, double encryption load. Well, you could tunnel to a web or rcp port, but I suppose the other end might require ssh on that net. So, you want to sftp or scp through a tunnel. I suppose it should work, but the connection is coming from a different host than the certificate supports, so I see lots of problems. ssh is going to smell a rat and balk!

Now, you could ssh from client host to proxy, both a) setting up a tunnel from client host port y to proxy port x and b) ssh on proxy to set up a tunnel from proxy port x to target server web port, so you can hit http://client_host:y/file_name with wget. The two tunnels would be end to end, and http uses one port/connection and no host verifiation, and you can easily control the port.

Last edited by DGPickett; 04-15-2011 at 02:10 PM..
# 7  
Old 04-15-2011
Hi dhpickett,

It's like you wrote: 'that net' just offers an sftp service, no web port, etc.

But really, I don't think we're on the same page :-) The purpose of my script is to upload files to an sftp server. The argument '-L' executes ssh (on the client) and tells it to listen on port 22000 and forward all traffic to 'proxy'; the ssh daemon on 'proxy' is then used to forward all traffic to 'server'. This is (and I'm sure you know this) basic forwarding. It works fine and we've been using it for a few weeks now.

The part that fails is when I try to capture the output of the function() that the ssh command is part of.

Thanks again for your replies.

Regards,
Willem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Tunnel using SSH

I am not clear with the part of concept of Tunneling using ssh. ssh -f -N -L 1029 192.168.1.47:25 james@192.168.1.47 I found out that above code works for me . but didn't quite well understood how ti works and need to ask you guys some questions. since we are using tunnel through ssh ... (2 Replies)
Discussion started by: lobsang
2 Replies

2. Solaris

Tunnel X over ssh for 11.3

Hello Solaris experts: Trying to bring the 11.3 gdm screen over ssh to a Linux Box: I did the following: 1. made chanes to /etc/ssh/sshd_config & bounced ssh daemon: # X11 tunneling options X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes 2. From the remote Linux box: ... (6 Replies)
Discussion started by: delphys
6 Replies

3. Proxy Server

WebSocket over SSH tunnel - is it possible?

Hello, I have a video streaming application that utilizes a WebSocket for the server <-> client communication. My goal is to make the video streaming service available over the internet in the cases where neither the server nor client have public IPs. One way to do this is over a VPN... (8 Replies)
Discussion started by: Vladislav
8 Replies

4. UNIX for Advanced & Expert Users

Ssh tunnel question

Hi all I have a suite of scripts that ssh to remote servers within a cluster and run some tests. This is done from a central server so that all of the test results can be captured in one location. Problem is I now have 509 tests and the number is growing. The scripts work by establishing a... (2 Replies)
Discussion started by: steadyonabix
2 Replies

5. IP Networking

Help with SSH tunnel?

I have a Java web app on machine (X) that needs to talk to an LDAP server (Y) on :636, but the LDAP server is only accessible on a particular network. I can login to a machine (Z) on that network from X, and this machine can talk to the LDAP server on :636. How can I tunnel so that X can... (2 Replies)
Discussion started by: spacegoose
2 Replies

6. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

7. Cybersecurity

RDP over SSH Tunnel

Hi all, I'm trying have an alternative way of connecting into a Corporate network. Mostly in case the VPN down as I cannot also change the security policy. I want to expose windows RDP over ssh tunnel. I have 3 hosts in my scenario 1- Host a : Windows 2k8 has no internet access just only an... (3 Replies)
Discussion started by: h@foorsa.biz
3 Replies

8. UNIX for Advanced & Expert Users

Stopping SSH tunnel

I have initiated a tunnel for vncserver. now i want to stop it. is there any way except sleep option? (2 Replies)
Discussion started by: majid.merkava
2 Replies

9. UNIX for Advanced & Expert Users

ssh decipher a tunnel

Two question here, but it's only one on the protocol point of view. If two persons use the same key to connect to a SSH server is there a risk they can decipher the other tunnel. In other terms is that less safe than if they have two separate keys. Same question if two persons use the same user... (2 Replies)
Discussion started by: moi
2 Replies

10. Programming

using a ssh tunnel with nx compression

hi everybody and thank you for this wondefrul forum this is my first thread posted here and i hope that i could find some help from your part (i am even sure) :D here is the situation: i am to develop an application of remote desktop access such as vnc, vpn and especially nx i want to develop... (0 Replies)
Discussion started by: bolboln01
0 Replies
Login or Register to Ask a Question