by whalesalad · 2y ago · 0 comments
scp remote.host:path.txt local
scp local remote.host:path
Need a fast proxy to browse the internet securely and bypass restrictions without a VPN? SSH SOCKS proxy! Supported by most operating systems, but I tend to use it directly via Firefox so that it is isolated to one browser. This starts a socks proxy on the desired port: ssh -D $port $host
Firefox has network settings, simply choose SOCKS, 127.0.0.1 as the IP and the specified port as the port. Then you're off to the races.Until we had proper VPN infrastructure to enter our VPC at AWS I would utilize this to view private vpc-only RMQ dashboards.
Love SSH!
https://support.mozilla.org/en-US/kb/how-use-firefox-contain...
For less trivial transfers (recursive structures, large collections that you want to sync with minimal time) rsync supports SSH as a transport medium out of the box so
scp remote.host:path.txt local
scp local remote.host:path
becomes rsync remote.host:path.txt local
rsync local remote.host:path
for the basics, then start adding the other options that you need: rsync some/local/dir me@remote.host:/target/ --recursive --times
rsync some/local/dir me@remote.host:/target/ --archive # archive does recursive and also preserves times, ownership, etc.
rsync some/local/dir me@remote.host:/target/ --recursive --delete-before --dry-run
… … …
In fact, I usually end up using rsync even for the basics, just out of habit typing that instead of scp. rsync source destination
or rsync source destination --recursive
with the only extra gotcha being that you need to be careful whether you need trailing /s on directories (sometimes where CP or scp would complain and exit, rsync will do something that isn't quite what you intended).The first complication you might hit is when you want to sync, including deleting files at the destination as needed, rather than just copying. This isn't _that_ complicated really, but caution is understandable because mistakes can cause unintended deletions. The --dry-run and verbose output options are your friend here, and the assurance that it won't delete anything unless you explicitly give it one if the --delete* options.
I still have PTSD from the time I played with the options and made the mistake of swapping source and destination, where the destination was a blank disk.
Time a 'tar | nc' sometime to a remove server, it'll blow away the rsync time.
It's like saying the classic reboot utility and systemd are the same thing just because modern Linux distros symlink the reboot command to systemctl. Or, to stretch a little further, like saying HTTP and HTTPS are the same thing just because most websites redirect one to the other.
There's no justification for spreading confusion and relying on a compatibility behavior for an obsolete command. That compatibility behavior is not present on pre-2022 distros, and may be removed again in the future once people are expected to have updated their scripts & whatnot. You're evangelizing SFTP, just use the SFTP command.
You are acknowledging my point - in this case they ARE the same thing. If it looks like a duck, quacks like a duck, and walks like a duck - it's a duck. This is like arguing symlinks are wrong and instead of `python` you must use `python3.12` even though they are ultimately identical. Read the man page for `scp` and read the man page for `sftp` and seriously tell me why I should use one over the other.
> That compatibility behavior is not present on pre-2022 distros
Who is using a pre-2022 distro reading this comment? And I have been using scp (with SSH, SFTP) for a lot longer than since 2022. Like over a decade.
Your comment reads like an HOA enforcer. Just raising fuss for no actual benefit.
e.g. I can run "sshuttle -r myserver example.com", and when I next load example.com in my web browser (without any special configuration) it'll be routed via `myserver`.
SSH is the best network service multi-tool. From remote shell, to file transfer, to network routing.
In this case you've got a network with some devices on it in location A, and a device in location B and you'd like to make B believe it's on the LAN of location A. Both a traditional VPN such as wireguard or OpenVPN and SSH with SOCKS can accomplish this.