5 ms·
> Did SSH originally have file-copying capabilities ssh basically sets up a secure connection between two hosts, then forwards its standard input to the stand
by ams6110 10y ago
> Did SSH originally have file-copying capabilities
ssh basically sets up a secure connection between two hosts, then forwards its standard input to the standard input of a program on the other side.
You can sort of simulate scp by something like:
cat my_file | ssh me@example.com "cat >my_remote_file"
- tyingq 10y agotar -cf - ./somedir | ssh remote '(cd /whatever;tar -xvf -)' I use that enough that I didn't need to look it up. Works the other direction as well. Was common with rsh before ssh existed. It's not as efficient as rsync, but I can tell where files will end up without re-reading a man page.
- contras1970 10y agotar -cf - ./somedir | ssh remote tar -xvf - -C /whatever
- Filligree 10y agoI mean, I'd encourage you to use && instead of ;...
- apk17 10y agoI still wonder why `cd` doesn't have a form `cd dir command...`, as in `cd dir tar xf -`.
- efaref 10y agoYou could quite easily write a script that does this: #!/bin/sh cd $1 shift exec "$@" It's a shame "in" is a reserved word, because that'd be a good name for it. Maybe "cde" for "cd-exec": tar c files | ssh dest cde /some/dir tar x
- apk17 10y agoMine is called cdx and includes 'env' functionality and a bit more. (https://github.com/apk/c-utils/blob/master/aenv.c https://github.com/apk/c-utils/blob/master/aenv.c)
- dasyatidprime 10y agoThe form I usually use is (cd TARGET && COMMAND), including the parentheses to make it a subshell. That seems close enough to not be worth adding features to something as simple as cd, given the basic shell philosophy of composability.