|
|
Network File Copy using SSH
Source: http://ultra.ap.krakow.pl/~bar/DOC/ssh_backup.html
Network File Copy using SSH Updated February 20, 2003
Please note that &&, ||, and -, are documented at the bottom of this page. tar cvf - . | gzip -c -1 | ssh user@host cat ">" remotefile.gz ssh target_address cat <localfile ">" remotefile ssh target_address cat <localfile - ">" remotefile cat localfile | ssh target_address cat ">" remotefile cat localfile | ssh target_address cat - ">" remotefile dd if=localfile | ssh target_address dd of=remotefile ssh target_address cat <localfile "|" dd of=remotefile ssh target_address cat - <localfile "|" dd of=remotefile ( cd SOURCEDIR && tar cf - . ) | ssh target_address "(cd DESTDIR && tar xvpf - )" ( cd SOURCEDIR && tar cvf - . ) | ssh target_address "(cd DESTDIR && cat - > remotefile.tar )" ( cd SOURCEDIR && tar czvf - . ) | ssh target_address "(cd DESTDIR && cat - > remotefile.tgz )" ( cd SOURCEDIR && tar cvf - . | gzip -1 -) | ssh target_address "(cd DESTDIR && cat - > remotefile.tgz )" ssh target_address "( nc -l -p 9210 > remotefile & )" && cat source-file | gzip -1 - | nc target_address 9210 cat localfile | gzip -1 - | ssh target_address cat ">" remotefile.gz PULL: ssh target_address cat remotefile > localfile ssh target_address dd if=remotefile | dd of=localfile ssh target_address cat "<" remotefile >localfile ssh target_address cat "<" remotefile.gz | gunzip >localfile COMPARE:
ssh target_address cat remotefile | diff - localfile cat localfile | ssh target_address diff - remotefile ###This one uses CPU cycles on the local server to compare the files: ssh target_address cat <localfile "|" diff - remotefile
Push: Push local file to remote server. Of course there is always ftp, scp2, nfs, smb and other methods as well.
The above methods make a great Ghost replacement. backup the local hard drive to a remote server or download an image from the remote server and place it on the local hard drive. RSH works just the same as SSH I'm sure, it's jut that ssh or ssh should give you better security. Note: Compressing and then transferring data is faster than transferring uncompressed data. Use compression before sending data over the wire to achieve faster data transfer speeds.
localfile and remotefile can be files, directories, images, hard drive partitions, or hard drives. ( cd SOURCEDIR && tar cf - . ) | (cd DESTDIR && tar xvpf - ) FTP VIEW: ftp> get file.gif "| xv -" ftp> get README "| more" FTP PUSH: ftp> put "| tar cvf - ." myfile.tar ftp> put "| tar cvf - . | gzip " myfile.tar.gz FTP PULL: ftp> get myfile.tar "| tar xvf -" Pipes and Redirects: zcat Fig.ps.Z | gv - gunzip -c Fig.ps.gz | gv - tar xvf mydir.tar tar xvf - < mydir.tar cat mydir.tar | tar xvf - tar cvf mydir.tar . tar cvf - . > mydir.tar tar cf - . | (cd ~/newdir; tar xf -) gunzip -c foo.gz > bar cat foo.gz | gunzip > bar zcat foo.gz > bar gzip -c foo > bar.gz cat foo | gzip > bar.gz cat foo | gzip > bar.gz
SSH Keys
These can be used separately or together as needed. The following examples will attempt The dash “-“ is used to reference either standard input or standard output. The context in which the dash is used is what determines whether it references standard input or standard output. |
|||
|
|
||||