On Wed, Feb 23, 2011 at 6:47 AM, David Frascone <d...@frascone.com> wrote:
>
> My office just started doing DMZ nonsense, so I have to bounce through an
> intermediary host to grab a file, sort of like this:
> ssh -f -N -q -L 2222:dmz_machine_ip:22 user@intermediary_machine_ip
> scp -P 2222 transformers.avi user@localhost:.
>
> So, my question is:  How can I grab the PID of that first ssh process, so I
> can kill it (and drop the tunnel) after the scp?
>

This doesn't answer your question for PIDs, but should solve the
overall problem.

Change your ssh command to
ssh -f -q -L 2222:dmz_machine_ip:22 user@intermediary_machine_ip sleep 60

This establishes the tunnel for a 60 second window then dies silently.
However, if port 2222 is still in use at the end of 60 seconds, ssh
keeps the tunnel open until you disconnect. So, there's no manual
cleanup required.

-- 
Rob Farmer

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to