Created
April 25, 2014 10:20
-
-
Save patoi/11284658 to your computer and use it in GitHub Desktop.
SSH commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUSH: | |
* 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: | |
This one uses CPU cycles on the remote server to compare the files: | |
* 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 | |
Explanation of &&, ||, and - | |
* && is shorthand for "if true then do" | |
* || is shorthand for "if false then do" | |
These can be used separately or together as needed. The following examples will attempt | |
to change directory to "/tmp/mydir"; you will get different results based on whether "/tmp/mydir" exists or not. | |
* cd /tmp/mydir && echo was able to change directory | |
* cd /tmp/mydir || echo was not able to change directory | |
* cd /tmp/mydir && echo was able to change directory || echo was not able to change to directory | |
* cd /tmp/mydir && echo success || echo failure | |
* cd /tmp/mydir && echo success || { echo failure; exit; } | |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment