<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: persistent ssh tunnel in a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411922#M82051</link>
    <description>Thanks Matt</description>
    <pubDate>Sun, 03 May 2009 12:47:57 GMT</pubDate>
    <dc:creator>Gilbert Standen_1</dc:creator>
    <dc:date>2009-05-03T12:47:57Z</dc:date>
    <item>
      <title>persistent ssh tunnel in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411920#M82049</link>
      <description>Ok, I create a tunnel from "home" to "work" via "gate":&lt;BR /&gt;&lt;BR /&gt;ssh  -l myuserid  -L 7777:work:22  gate&lt;BR /&gt;&lt;BR /&gt;and leave this terminal session open and now I can make use of my tunnel for scp etc.&lt;BR /&gt;&lt;BR /&gt;But suppose I want to create a persistent tunnel but I want to do it in a script or something?  I saw one author who recommended this:&lt;BR /&gt;&lt;BR /&gt;ssh  -l myuserid  -L 7777:work:22  gate  cat -&lt;BR /&gt;&lt;BR /&gt;where the author has used "cat" to keep the connection open (or other command which does not finish could be used). If no "non-finishing" command is provided, then a shell opens and then you need a controlling terminal and cannot use the ssh command in a script.  Moreover, some servers have protections against running things like "cat -" and so on a well-secured server you won't easily be able to use some "non-finishing" command like that.&lt;BR /&gt;&lt;BR /&gt;So how do you create a persistent tunnel in a script without having a controlling terminal?  Is that possible?&lt;BR /&gt;&lt;BR /&gt;Thanks, Gil</description>
      <pubDate>Sat, 02 May 2009 14:26:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411920#M82049</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2009-05-02T14:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: persistent ssh tunnel in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411921#M82050</link>
      <description>If your SSH client is reasonably up to date, something like this might do the trick:&lt;BR /&gt;&lt;BR /&gt;ssh -l myuserid -L 7777:work:22 gate -o ExitOnForwardFailure=yes -n -N &amp;amp;&lt;BR /&gt;# capture the PID of the SSH process:&lt;BR /&gt;TUNNELPID=$!&lt;BR /&gt;&lt;BR /&gt;To remove the tunnel when you're done, use "kill $TUNNELPID".&lt;BR /&gt;&lt;BR /&gt;Options:&lt;BR /&gt;-n removes the need for a controlling terminal.&lt;BR /&gt;-N says we are running SSH to get port forwardings only, remote command is not needed.&lt;BR /&gt;-o ExitOnForwardFailure=yes means that SSH will terminate if a tunnel cannot be set up.&lt;BR /&gt;&lt;BR /&gt;You might use the "-f" option instead of "&amp;amp;", but then capturing the PID will be more difficult...&lt;BR /&gt;&lt;BR /&gt;SSH has a lot of useful options: reading the man page helps.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Sat, 02 May 2009 19:39:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411921#M82050</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2009-05-02T19:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: persistent ssh tunnel in a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411922#M82051</link>
      <description>Thanks Matt</description>
      <pubDate>Sun, 03 May 2009 12:47:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/persistent-ssh-tunnel-in-a-script/m-p/4411922#M82051</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2009-05-03T12:47:57Z</dc:date>
    </item>
  </channel>
</rss>

