Re: [gentoo-user] ssh and tar combined?
On Saturday 31 December 2005 14:26, Neil Bothwick wrote: On Fri, 30 Dec 2005 18:58:17 +0100, Alexander Skwar wrote: tar outputs to stdout by default, Not always. From man tar -f, --file [HOSTNAME:]F use archive file or device F (default -, meaning stdin/stdout) So -f - is unnecessary, but harmless. That is true for GNU tar, but not for other versions, so specifying -f - is the safest solution. For example the man page tar on Solaris 2.8 says: f File. Use the tarfile argument as the name of the tarfile. If f is specified, /etc/default/tar is not searched. If f is omitted, tar will use the device indicated by the TAPE environment variable, if set; otherwise, it will use the default values defined in /etc/default/tar. If the name of the tarfile is '-', tar writes to the standard output or reads from the standard input, whichever is appropriate. tar can be used as the head or tail of a pipeline. tar can also be used to move hierarchies with the command: example% cd fromdir; tar cf - .| (cd todir; tar xfBp -) The file /etc/default/tar contains a list of tape devices. So on Solaris 2.8 if -f is not specified and $TAPE is not set, which it isn't by default, then tar will use a tape device *not* stdin/stdout Steve -- Steve EvansE-mail: mailto:[EMAIL PROTECTED] WEB:http://www.gorbag.com Registered Linux user #217906: http://counter.li.org Public Encryption Key: http://www.gorbag.com/public-key.html Now playing: Nina Simone - It might as well be spring 2.6.14-gentoo-r5 Intel(R) Pentium(R) 4 CPU 3.00GHz GNU/Linux 14:50:29 up 2 days, 21:41, 6 users, load average: 0.21, 0.14, 0.14 I didn't know he was dead; I thought he was British. pgpWwhGXl15ba.pgp Description: PGP signature
Re: [gentoo-user] ssh and tar combined?
The file /etc/default/tar contains a list of tape devices. So on Solaris 2.8 if -f is not specified and $TAPE is not set, which it isn't by default, then tar will use a tape device *not* stdin/stdout Steve -- Thanks, Steve. This is the point I was trying to make, but I'm at home with only linux and mac boxes... My point was if you specify the arguments you want, every time, you don't usually have to stop and wonder what the default behavior is on a given platform. Not a problem if you're always on linux or know for sure that you're hitting gnu tar. But for those of us who support a variety of platforms, not making assumptions about defaults is a good habit to get into (not speaking only of tar). -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] ssh and tar combined?
On Sat, 31 Dec 2005 08:53:45 -0600, John Jolet wrote: But you are correct, today this -f - is unnecessary. Tomorrow? who knows what decisions might be made regarding default output. My point is, being precise costs nothing... nothing but a few keystrokes. That's a fair point. The main reason for my initial reply was to comment on your use of dd. -- Neil Bothwick Echo Speak: Whale oil beef hooked signature.asc Description: PGP signature
Re: [gentoo-user] ssh and tar combined?
Neil Bothwick schrieb: On Fri, 30 Dec 2005 18:58:17 +0100, Alexander Skwar wrote: tar outputs to stdout by default, Not always. From man tar So, why do you suppose that the command is called tape (file) archiver? While you're right as far as GNU tar is concerned, you're wrong as far as the default of tar is concerned. Eg. see the man page of tar on hp-ux, http://docs.hp.com/en/B2355-90690/tar.1.html: | f | Use the next arg argument as the name of the archive instead | of the default, /dev/rmt/0m. Or Solaris 10 http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9u1?q=tara=view: | f | | File. Use the tarfile argument as the name of the tarfile. If | is specified, /etc/default/tar is not searched. If f is omitted, | tar will use the device indicated by the TAPE environment variable, | if set. Otherwise, tar will use the default values defined in | /etc/default/tar So -f - is unnecessary, but harmless. No, f is necessary if you don't wish to rely on unknown defaults. Even with GNU tar, you don't know FOR SURE if -f - is the default. Who knows? Maybe DEFAULT_ARCHIVE was set to something else while building? Alexander Skwar -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] ssh and tar combined?
On Dec 30, 2005, at 9:21 AM, Neil Bothwick wrote: On Wed, 28 Dec 2005 08:22:26 -0600, John Jolet wrote: or ssh sourcebox tar -czvf - /path/to/be/backed/up | dd of=target.tar.gz tar outputs to stdout be default, so -f - is redundant, as is the use of dd. All you need is ssh hostname tar cf /source/path backup.tar.gz hmm, I'm not sure this behavior is consistent across all versions of tar and all versions of ssh. I could be wrong, but the process I outlined will work on linux, aix, solaris, bsd, at least (those are the ones i've tested). but hey, I could be wrong...just because method a works doesn't mean it's the only method...that's the beauty of unix. -- Neil Bothwick Whats the difference between a magician and a brothel? One has a cunning array of stunts, -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] ssh and tar combined?
On Fri, 30 Dec 2005 09:44:09 -0600, John Jolet wrote: tar outputs to stdout be default, so -f - is redundant, as is the use of dd. All you need is ssh hostname tar cf /source/path backup.tar.gz hmm, I'm not sure this behavior is consistent across all versions of tar and all versions of ssh. The part about stdout being the default is consistent, -f overrides the default. To maintain consistency across ssh versions, it may be safer to use ssh backup.tar.gz hostname tar cf /source/path -- Neil Bothwick Windows95 - crash compatible on Windows 3.x signature.asc Description: PGP signature
Re: [gentoo-user] ssh and tar combined?
Neil Bothwick schrieb: On Fri, 30 Dec 2005 09:44:09 -0600, John Jolet wrote: tar outputs to stdout be default, so -f - is redundant, as is the use of dd. All you need is ssh hostname tar cf /source/path backup.tar.gz hmm, I'm not sure this behavior is consistent across all versions of tar and all versions of ssh. The part about stdout being the default is consistent, No, it's not. By default, tar writes to a tape device. To maintain consistency across ssh versions, it may be safer to use ssh backup.tar.gz hostname tar cf /source/path Uh? [EMAIL PROTECTED] /tmp $ ssh t server tar cf /tmp/. [EMAIL PROTECTED]'s password: tar: Cowardly refusing to create an empty archive Try `tar --help' or `tar --usage' for more information. Ah, You wanted to leave out the f :) But why should 'ssh backup.tar hostname tar c /source/path' be more consistent across *SSH* versions than 'ssh hostname tar c /source/path backup.tar'? Isn't that just a question wrt. the shell? Alexander Skwar -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] ssh and tar combined?
On Dec 28, 2005, at 2:04 AM, Alexander Skwar wrote: Mick schrieb: Ideally I would like to connect and tar | scp the directories/ files from one box to another in a single motion. Use ssh instead: tar | ssh [EMAIL PROTECTED] cat foo.tar or ssh sourcebox tar -czvf - /path/to/be/backed/up | dd of=target.tar.gz this will ssh into the other box, create the tar to stdout, pipe stdout from the ssh stream to dd, who's default input is stdin, and output the file. Alexander Skwar -- gentoo-user@gentoo.org mailing list -- gentoo-user@gentoo.org mailing list
RE: [gentoo-user] ssh and tar combined?
-Original Message- From: John Jolet [mailto:[EMAIL PROTECTED] Sent: 28 December 2005 14:22 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] ssh and tar combined? On Dec 28, 2005, at 2:04 AM, Alexander Skwar wrote: Mick schrieb: Ideally I would like to connect and tar | scp the directories/ files from one box to another in a single motion. Use ssh instead: tar | ssh [EMAIL PROTECTED] cat foo.tar or ssh sourcebox tar -czvf - /path/to/be/backed/up | dd of=target.tar.gz this will ssh into the other box, create the tar to stdout, pipe stdout from the ssh stream to dd, who's default input is stdin, and output the file. Thanks Alexander, I'll try it out when I get home. -- Regards, Mick -- gentoo-user@gentoo.org mailing list
[gentoo-user] ssh and tar combined?
Hi All, One day I hope to learn how to use ssh and the associated commands. So far I have been struggling just to copy a file from one box (192.168.0.3) to another (192.168.0.2). This is what I get, but and since I can't find the 'copied' file . . . I suspect it fails. I don't understand why: == # ssh [EMAIL PROTECTED] Password: [EMAIL PROTECTED] scp -pv [EMAIL PROTECTED]:/mnt/sda14/sda10_home.tar . Executing: program /usr/bin/ssh host 192.168.0.3, user root, command scp -v -p - f /mnt/sda14/sda10_home.tar OpenSSH_3.8.1p1 Debian-8.sarge.4, OpenSSL 0.9.7e 25 Oct 2004 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: /etc/ssh/ssh_config line 33: Deprecated option RhostsAuthentication debug1: /etc/ssh/ssh_config line 37: Deprecated option FallBackToRsh debug1: /etc/ssh/ssh_config line 38: Deprecated option UseRsh debug1: Connecting to 192.168.0.3 [192.168.0.3] port 22. debug1: Connection established. debug1: read PEM private key done: type DSA debug1: read PEM private key done: type RSA debug1: identity file /root/.ssh/identity type -1 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: Remote protocol version 1.99, remote software version OpenSSH_3.8.1p1 De bian-8.sarge.4 debug1: match: OpenSSH_3.8.1p1 Debian-8.sarge.4 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_3.8.1p1 Debian-8.sarge.4 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server-client aes128-cbc hmac-md5 none debug1: kex: client-server aes128-cbc hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(102410248192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host '192.168.0.3' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interacti ve debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Trying private key: /root/.ssh/id_rsa debug1: Trying private key: /root/.ssh/id_dsa debug1: Next authentication method: keyboard-interactive Password: debug1: Authentication succeeded (keyboard-interactive). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending command: scp -v -p -f /mnt/sda14/sda10_home.tar Sending file modes: C0644 536002560 sda10_home.tar sda10_home.tar100% 511MB 24.3MB/s 00:21 debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 21.5 seconds debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0 debug1: Exit status 0 [EMAIL PROTECTED] exit logout Connection to 192.168.0.3 closed. = Ideally I would like to connect and tar | scp the directories/files from one box to another in a single motion. Any advice to help me understand how to make this work, or why the above attempt fails would be much appreciated. -- Regards, Mick -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] ssh and tar combined?
On Tue, 2005-12-27 at 23:53 +, Mick wrote: Hi All, One day I hope to learn how to use ssh and the associated commands. So far I have been struggling just to copy a file from one box (192.168.0.3) to another (192.168.0.2). This is what I get, but and since I can't find the 'copied' file . . . I suspect it fails. I don't understand why: == # ssh [EMAIL PROTECTED] Password: [EMAIL PROTECTED] scp -pv [EMAIL PROTECTED]:/mnt/sda14/sda10_home.tar . --CUT--- Ideally I would like to connect and tar | scp the directories/files from one box to another in a single motion. Any advice to help me understand how to make this work, or why the above attempt fails would be much appreciated. -- Regards, Mick scp is used in the same manner you use cp. It seems that you have ssh'd into your other box then are trying to scp to yourself. try this. comp1# scp root@comp2:/path/to/file.tar /path/to/local/ this will cp from comp2 to comp1 :) -Lares Lares Moreau [EMAIL PROTECTED] | LRU: 400755 http://counter.li.org lares/irc.freenode.net | Gentoo x86 Arch Tester | ::0 Alberta, Canada Public Key: 0D46BB6E @ subkeys.pgp.net | Encrypted Mail Preferred Key fingerprint = 0CA3 E40D F897 7709 3628 C5D4 7D94 483E 0D46 BB6E signature.asc Description: This is a digitally signed message part
Re: [gentoo-user] ssh and tar combined?
On Tue, 2005-12-27 at 23:53 +, Mick wrote: Ideally I would like to connect and tar | scp the directories/files from one box to another in a single motion. Any advice to help me understand how to make this work, or why the above attempt fails would be much appreciated. Locallly : tar lcf - . | (cd /other/area/store; tar -xpvf - ) tar lcf - /path/to/file | (cd /other/area/store; tar -xpvf - ) To specify directories or files to exclude, we can use the option -- exclude tar --exclude File1 --exclude Dir1 -lcf - . | ( cd /other/area; tar -xvpf - ) via SSH remotely : tar -czf - /directory/to/copy | ssh systemB tar -xzvf - -C /tmp How's that?? Bear in mind that SSH will use some overhead due to encryption. (you can change the cipher to blowfish if you want/is not that paranoid :-) -- Ow Mun Heng Gentoo/Linux on DELL D600 1.4Ghz 1.5GB RAM 98% Microsoft(tm) Free!! Neuromancer 10:27:28 up 1 day, 1:09, 6 users, load average: 0.73, 0.83, 1.09 -- gentoo-user@gentoo.org mailing list