<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Howto: Use tar Command Through Network Over SSH Session</title> <atom:link href="http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: bla</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-67516</link> <dc:creator>bla</dc:creator> <pubDate>Tue, 24 Jan 2012 11:38:03 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-67516</guid> <description>Easier:
tar -czf - bla &#124; ssh oherhost &quot;(cd /somewher/to/restore &amp;&amp; tar -xzf -)&quot;</description> <content:encoded><![CDATA[<p>Easier:</p><p>tar -czf &#8211; bla | ssh oherhost &#8220;(cd /somewher/to/restore &amp;&amp; tar -xzf -)&#8221;</p> ]]></content:encoded> </item> <item><title>By: Stephen Bunn</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-61284</link> <dc:creator>Stephen Bunn</dc:creator> <pubDate>Thu, 04 Aug 2011 01:11:49 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-61284</guid> <description>So how exactly would your tar up a 10GB partition with less than 1GB of space left? The original author&#039;s solution works very nice, as does your solution.  They are just used for two separate things.</description> <content:encoded><![CDATA[<p>So how exactly would your tar up a 10GB partition with less than 1GB of space left? The original author&#8217;s solution works very nice, as does your solution.  They are just used for two separate things.</p> ]]></content:encoded> </item> <item><title>By: Jose</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-60188</link> <dc:creator>Jose</dc:creator> <pubDate>Thu, 23 Jun 2011 12:15:13 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-60188</guid> <description>the next guy thanks you very much</description> <content:encoded><![CDATA[<p>the next guy thanks you very much</p> ]]></content:encoded> </item> <item><title>By: Bennie Kahler-Venter</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-55970</link> <dc:creator>Bennie Kahler-Venter</dc:creator> <pubDate>Thu, 24 Feb 2011 12:16:38 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-55970</guid> <description>GNU tar:
tar jcvf user@host:/somedir/file.tar.bz2 --rsh-command=/usr/bin/ssh  /sourcedir/</description> <content:encoded><![CDATA[<p>GNU tar:</p><p>tar jcvf user@host:/somedir/file.tar.bz2 &#8211;rsh-command=/usr/bin/ssh  /sourcedir/</p> ]]></content:encoded> </item> <item><title>By: Pablo Lorenzzoni</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-55765</link> <dc:creator>Pablo Lorenzzoni</dc:creator> <pubDate>Fri, 18 Feb 2011 20:13:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-55765</guid> <description>In my experience, &quot;rsync over ssh&quot; is much faster than &quot;tar &#124; ssh&quot;. Both are faster than scp, though. The only advantage of &quot;tar &#124; ssh&quot;, IMHO, is not needing to have rsync in the remote host...</description> <content:encoded><![CDATA[<p>In my experience, &#8220;rsync over ssh&#8221; is much faster than &#8220;tar | ssh&#8221;. Both are faster than scp, though. The only advantage of &#8220;tar | ssh&#8221;, IMHO, is not needing to have rsync in the remote host&#8230;</p> ]]></content:encoded> </item> <item><title>By: gUI</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-51253</link> <dc:creator>gUI</dc:creator> <pubDate>Thu, 02 Dec 2010 14:39:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-51253</guid> <description>Thanks a lot ! Really helpfull.
In my case I wanted to untar. The solution is :
ssh serveur &quot;cat file.tar&quot; &#124; untar -xvf -</description> <content:encoded><![CDATA[<p>Thanks a lot ! Really helpfull.</p><p>In my case I wanted to untar. The solution is :</p><p>ssh serveur &#8220;cat file.tar&#8221; | untar -xvf -</p> ]]></content:encoded> </item> <item><title>By: DucQuoc.wordpress.com</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-50602</link> <dc:creator>DucQuoc.wordpress.com</dc:creator> <pubDate>Mon, 08 Nov 2010 12:57:45 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-50602</guid> <description>Is there some simple method to copy file through some kind of &quot;ssh chain&quot; ?
Assuming that I&#039;m at &quot;homepc&quot; , can connect via SSH to &quot;remote1&quot; , and from &quot;remote1&quot; I can only connect SSH to &quot;remote2&quot; .
Which is the &quot;one-liner&quot; to copy a file from &quot;remote2&quot; to &quot;homepc&quot; ?
Let&#039;s say it&#039;s &quot;remote2:/repository/somefile.war&quot;  (I googled around but not found easy method)</description> <content:encoded><![CDATA[<p>Is there some simple method to copy file through some kind of &#8220;ssh chain&#8221; ?<br
/> Assuming that I&#8217;m at &#8220;homepc&#8221; , can connect via SSH to &#8220;remote1&#8243; , and from &#8220;remote1&#8243; I can only connect SSH to &#8220;remote2&#8243; .</p><p>Which is the &#8220;one-liner&#8221; to copy a file from &#8220;remote2&#8243; to &#8220;homepc&#8221; ?<br
/> Let&#8217;s say it&#8217;s &#8220;remote2:/repository/somefile.war&#8221;  (I googled around but not found easy method)</p> ]]></content:encoded> </item> <item><title>By: carlos</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-47520</link> <dc:creator>carlos</dc:creator> <pubDate>Wed, 26 May 2010 15:02:28 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-47520</guid> <description>And why not tar jxf user@remote.com:some_archive.tar.bz2 ? It will do the ssh for you, no need to do the ssh yourself (I don&#039;t remember if this was in Debian Lenny or Ubuntu Lucid... maybe older versions/other versions too).</description> <content:encoded><![CDATA[<p>And why not tar jxf <a
href="mailto:user@remote.com">user@remote.com</a>:some_archive.tar.bz2 ? It will do the ssh for you, no need to do the ssh yourself (I don&#8217;t remember if this was in Debian Lenny or Ubuntu Lucid&#8230; maybe older versions/other versions too).</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-46694</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Thu, 01 Apr 2010 22:01:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-46694</guid> <description>Vivek, There are at least 3 typos of duplicated ssh (ssh ssh).</description> <content:encoded><![CDATA[<p>Vivek, There are at least 3 typos of duplicated ssh (ssh ssh).</p> ]]></content:encoded> </item> <item><title>By: Henno Täht</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-46488</link> <dc:creator>Henno Täht</dc:creator> <pubDate>Thu, 18 Mar 2010 07:00:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-46488</guid> <description>I recently needed to copy entire directory structure from one machine to another, preserving symlinks, owners and dates. I&#039;ve done this tens of times before with tar and ssh but this time it didn&#039;t work.
Although I didn&#039;t use the -h option, tar nevertheless  followed symlinks and not recreated them on other side. Distro was Ubuntu 8.04. When I tried it with a small set of files, it worked, though, but I needed the entire tree. I never figured it out why it acted like that.
I was finally able to solve my problem by using rsync and after inital setup it worked very well. So for anyone stumbling over the same rock, here&#039;s some examples getting it done with rsync:
http://www.commandlinefu.com/commands/matching/rsync/cnN5bmM=/sort-by-votes</description> <content:encoded><![CDATA[<p>I recently needed to copy entire directory structure from one machine to another, preserving symlinks, owners and dates. I&#8217;ve done this tens of times before with tar and ssh but this time it didn&#8217;t work.</p><p>Although I didn&#8217;t use the -h option, tar nevertheless  followed symlinks and not recreated them on other side. Distro was Ubuntu 8.04. When I tried it with a small set of files, it worked, though, but I needed the entire tree. I never figured it out why it acted like that.</p><p>I was finally able to solve my problem by using rsync and after inital setup it worked very well. So for anyone stumbling over the same rock, here&#8217;s some examples getting it done with rsync:<br
/> <a
href="http://www.commandlinefu.com/commands/matching/rsync/cnN5bmM=/sort-by-votes" rel="nofollow">http://www.commandlinefu.com/commands/matching/rsync/cnN5bmM=/sort-by-votes</a></p> ]]></content:encoded> </item> <item><title>By: Rich</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-46478</link> <dc:creator>Rich</dc:creator> <pubDate>Wed, 17 Mar 2010 14:53:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-46478</guid> <description>Anderson, the use of “cat” in your example is completely unnecessary.
&lt;code&gt;tar czvf - /somedir &#124; ssh user@host &quot;tar xvzf - -C /outputdir&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Anderson, the use of “cat” in your example is completely unnecessary.</p><p><code>tar czvf - /somedir | ssh user@host "tar xvzf - -C /outputdir</code></p> ]]></content:encoded> </item> <item><title>By: Anderson Brandão</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45925</link> <dc:creator>Anderson Brandão</dc:creator> <pubDate>Wed, 10 Feb 2010 00:48:01 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45925</guid> <description>Another way would be using tar in both ends, as the example below:
&lt;code&gt; tar czvf - /somedir &#124; ssh user@host &quot;cat - &#124; tar xzfv - -C /outputdir&quot; &lt;/code&gt;</description> <content:encoded><![CDATA[<p>Another way would be using tar in both ends, as the example below:</p><p><code> tar czvf - /somedir | ssh user@host "cat - | tar xzfv - -C /outputdir" </code></p> ]]></content:encoded> </item> <item><title>By: Anderson Brandão</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45924</link> <dc:creator>Anderson Brandão</dc:creator> <pubDate>Wed, 10 Feb 2010 00:39:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45924</guid> <description>Another way would be using tar in both ends, as the example below:
&lt;code&gt; tar czvf - /somedir &#124; ssh user@host &quot;cat - &#124; tar xzfv - -C /outputdir &lt;/code&gt;</description> <content:encoded><![CDATA[<p>Another way would be using tar in both ends, as the example below:</p><p><code> tar czvf - /somedir | ssh user@host "cat - | tar xzfv - -C /outputdir </code></p> ]]></content:encoded> </item> <item><title>By: Henno Täht</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45394</link> <dc:creator>Henno Täht</dc:creator> <pubDate>Fri, 01 Jan 2010 18:55:23 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45394</guid> <description>Typo fix2:
left the server out:
ssh -Ct serverA &quot;stty -onlcr; sudo tar -cpf - -X /tmp/exclusion.list / 2&gt; /dev/null&quot; &#124; ssh serverB &quot;cd /tmp; tar cvpf -&quot;</description> <content:encoded><![CDATA[<p>Typo fix2:<br
/> left the server out:<br
/> ssh -Ct serverA &#8220;stty -onlcr; sudo tar -cpf &#8211; -X /tmp/exclusion.list / 2&gt; /dev/null&#8221; | ssh serverB &#8220;cd /tmp; tar cvpf -&#8221;</p> ]]></content:encoded> </item> <item><title>By: Henno Täht</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45393</link> <dc:creator>Henno Täht</dc:creator> <pubDate>Fri, 01 Jan 2010 18:51:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45393</guid> <description>Typo fix:
1) &lt;code&gt;ssh -Ct serverA &quot;sudo hostname&quot;&lt;/code&gt;
2) ...for every CR (0×13) an extra LF character will be injected (0×10) for proper displaying on terminal.</description> <content:encoded><![CDATA[<p>Typo fix:<br
/> 1) <code>ssh -Ct serverA "sudo hostname"</code></p><p>2) &#8230;for every CR (0×13) an extra LF character will be injected (0×10) for proper displaying on terminal.</p> ]]></content:encoded> </item> <item><title>By: Henno Täht</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45392</link> <dc:creator>Henno Täht</dc:creator> <pubDate>Fri, 01 Jan 2010 18:47:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45392</guid> <description>Here&#039;s one that worked for me recently:
I had to copy all the files from server A to a directory in server B  (in order to have full replica of A), using man-in-the-middle server (because that IP was the only one allowed to connect).
The trouble was that I only had sudo rights on the first server and there were absolutely all ports closed (both ways) except incoming 22 for my ip and incoming 80 and 443 for serving web. No way to ssh out of that box (fw blocked outgoing syn packets)
First I had to &quot;initialize&quot; sudo so that I wouldn&#039;t be asked a password which would later be asked within the pipe so I can&#039;t provide it then  (you recognize it by the infinite delay in the beginning while files are not appearing to the other side).
&lt;code&gt;ssh -Ct serverA &quot;sudo hostname&lt;/code&gt;
Password:
-C uses compression,
-t forces assigning a terminal (RHEL 5.1 by default requires terminal)
I guess this can be achieved also by just sshing in and issuing the same command there. Hostname is just a random command to get sudo to ask for password (which it remembers for the next 15 minutes).
Now for the fun part:
&lt;code&gt;ssh -Ct &quot;stty -onlcr;  sudo tar -cpf - -X /tmp/exclusion.list / 2&gt; /dev/null&quot; &#124; ssh serverB &quot;cd /tmp; tar cvpf -&quot;&lt;/code&gt;
stty -onlcr fixes a problem that arises with using forced terminal: for every CR (0x13) an extra LF character will be injected (0x13) for proper displaying on terminal. Only we&#039;re actually not using a terminal but passing the bitstream through the ssh tunnel to tar.
-p preserves files&#039; permissions
-X specifies an exclusion file (directories I don&#039;t want to be copied like /dev, /proc and /sys)
/ is what I want to be tarred :)
2&gt; /dev/null sends tar commentary to the darkest of places. Without it you&#039;ll get tar&#039;s own chatter within the data stream.
Hope this will be useful to someone (like myself, later on)</description> <content:encoded><![CDATA[<p>Here&#8217;s one that worked for me recently:</p><p>I had to copy all the files from server A to a directory in server B  (in order to have full replica of A), using man-in-the-middle server (because that IP was the only one allowed to connect).</p><p>The trouble was that I only had sudo rights on the first server and there were absolutely all ports closed (both ways) except incoming 22 for my ip and incoming 80 and 443 for serving web. No way to ssh out of that box (fw blocked outgoing syn packets)</p><p>First I had to &#8220;initialize&#8221; sudo so that I wouldn&#8217;t be asked a password which would later be asked within the pipe so I can&#8217;t provide it then  (you recognize it by the infinite delay in the beginning while files are not appearing to the other side).</p><p><code>ssh -Ct serverA "sudo hostname</code><br
/> Password:</p><p>-C uses compression,<br
/> -t forces assigning a terminal (RHEL 5.1 by default requires terminal)</p><p>I guess this can be achieved also by just sshing in and issuing the same command there. Hostname is just a random command to get sudo to ask for password (which it remembers for the next 15 minutes).</p><p>Now for the fun part:</p><p><code>ssh -Ct "stty -onlcr;  sudo tar -cpf - -X /tmp/exclusion.list / 2&gt; /dev/null" | ssh serverB "cd /tmp; tar cvpf -"</code></p><p>stty -onlcr fixes a problem that arises with using forced terminal: for every CR (0&#215;13) an extra LF character will be injected (0&#215;13) for proper displaying on terminal. Only we&#8217;re actually not using a terminal but passing the bitstream through the ssh tunnel to tar.</p><p>-p preserves files&#8217; permissions<br
/> -X specifies an exclusion file (directories I don&#8217;t want to be copied like /dev, /proc and /sys)<br
/> / is what I want to be tarred :)<br
/> 2&gt; /dev/null sends tar commentary to the darkest of places. Without it you&#8217;ll get tar&#8217;s own chatter within the data stream.</p><p>Hope this will be useful to someone (like myself, later on)</p> ]]></content:encoded> </item> <item><title>By: zauberkeks</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-45323</link> <dc:creator>zauberkeks</dc:creator> <pubDate>Sun, 27 Dec 2009 08:56:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-45323</guid> <description>Hi,
thank you for your script snippets, one of these is just backing up some giga bytes across the network. But I notices a typo, a unnecessary &quot;ssh&quot; behind some of the pipe symbols. For example:
&lt;code&gt;# tar cvzf - /wwwdata &#124; ssh &lt;b&gt;ssh&lt;/b&gt; root@192.168.1.201 &quot;cat &gt; /dev/nst0&quot;&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Hi,<br
/> thank you for your script snippets, one of these is just backing up some giga bytes across the network. But I notices a typo, a unnecessary &#8220;ssh&#8221; behind some of the pipe symbols. For example:<br
/> <code># tar cvzf - /wwwdata | ssh <b>ssh</b> <a
href="mailto:root@192.168.1.201">root@192.168.1.201</a> "cat &gt; /dev/nst0"</code></p> ]]></content:encoded> </item> <item><title>By: bram</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-43731</link> <dc:creator>bram</dc:creator> <pubDate>Thu, 17 Sep 2009 16:52:10 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-43731</guid> <description>or using netcat
$ tar czvf - /var/spool &#124; nc -l 12345
$ nc host 12345 &#124; tar xzvf -
it&#039;s not secure, but it doesn&#039;t require much</description> <content:encoded><![CDATA[<p>or using netcat</p><p>$ tar czvf &#8211; /var/spool | nc -l 12345<br
/> $ nc host 12345 | tar xzvf -</p><p>it&#8217;s not secure, but it doesn&#8217;t require much</p> ]]></content:encoded> </item> <item><title>By: sibia</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-43181</link> <dc:creator>sibia</dc:creator> <pubDate>Mon, 17 Aug 2009 11:53:32 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-43181</guid> <description>Hi,
is there a way to write a shell script that can automatically write data to tape every end of day?</description> <content:encoded><![CDATA[<p>Hi,</p><p>is there a way to write a shell script that can automatically write data to tape every end of day?</p> ]]></content:encoded> </item> <item><title>By: henno</title><link>http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/#comment-42848</link> <dc:creator>henno</dc:creator> <pubDate>Sun, 02 Aug 2009 08:32:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/howto-use-tar-command-through-network-over-ssh-session.php#comment-42848</guid> <description>Sorry for being dumb but... so what is exactly the most efficient command to get local data to the remote server?</description> <content:encoded><![CDATA[<p>Sorry for being dumb but&#8230; so what is exactly the most efficient command to get local data to the remote server?</p> ]]></content:encoded> </item> </channel> </rss>
