TIL that the scp command does not, by default, compress files it transfers, and that you need to add the -C flag to make it do that, and by doing that I have sped up my transfer speed about 40x, and without this knowledge I have probably wasted literally days of my life waiting for things in the past.
Some may say "why are you using scp rather than rsync" and to that I say, rsync has even more ridiculously complicated flags to learn.
@jimbob eh, rsync is one of those things where you pretty much always use the same flags. -avzr from memory. Just copy it from the last script you used it in. :)
@SteveBennett @jimbob I always get the trailing slash wrong, and then rsync copies the directory inside the directory...
@beto @SteveBennett @jimbob this is me. I write a new script using sync about once every couple of years. I always end up using trial and error to rediscover whether I need a slash or not. And I still have directories out there with extra levels where I guessed wrong and didn’t realise 😊 #VeryOccasionalLinuxAdmin
@beto @SteveBennett @jimbob I make the source and destination paths look the same near the end of each of them and always with a trailing slash and it seems to always work out.

@jimbob

No shame because for me I would just get compression with

`tar -czf - somedir | ssh somehost tar -xzf -`

Because yanno . . . .

@MichaelTBacon @jimbob well if you want to use a different compression algorithm that might still be what is needed!
@MichaelTBacon @jimbob no v, on dest side?! Blind faith! I am impressed, i lack the patience to believe it's doing anything :)

@snosrapkungfu @jimbob

Nah, that's what the other terminal window is for . . . ;)

(but TBH the destination side really should look something like `ssh somehost bash -c 'cd /actual/target/directory; tar -xzf -'`. I mean you don't want it just dumping in the home dir, right?)

@MichaelTBacon @jimbob since I discovered it I prefer : tar -czf - somedir | pv | ssh somehost tar -xzf -
@MichaelTBacon @jimbob Also avoids walking the tree twice and adding roundtrips. But surely "ssh somehost 'cd somedir; tar xfz -'" there's probably a tar option for that that might be the same with GNU and BSD tar but I've been doing it this way for 30-40 years now except when I had to use "cpio -iforgettheoptions".
@jimbob Never knew that scp did compression. I would have bzip2 first, or used rsync. -azv
@jimbob I usually use rsync -avP ... and that doesn't compress by default, it seems. I'll have to try -avzP next time.
@kboyd @jimbob Remember cpio? I barely do, but the standard flags of -icdumv are still still clear in my mind.
@jimbob also scp is included with windows, rsync is not 😀
@Paxxi @jimbob Have I genuinely been away from Windows so long that it's gotten... useful tools? Is this reality? Am I real?
@penryu @jimbob things have happened, it ships proper curl, albeit an old version afaik, ssh client and server and it's got a package manager(sort of) winget

@Paxxi @jimbob I'm impressed. Canonical has been a good influence, I take it?

I don't suppose there's a reasonable terminal emulator? Or is putty still a thing? Or is WSL a better option?

@penryu @jimbob there is one, windows terminal, it's not included by default https://github.com/microsoft/terminal
GitHub - microsoft/terminal: The new Windows Terminal and the original Windows console host, all in the same place!

The new Windows Terminal and the original Windows console host, all in the same place! - microsoft/terminal

GitHub
@penryu @Paxxi @jimbob I don't think you can run a local CMD shell in putty, but if I'm wrong and someone points that out I'll be delighted.

@dragonfrog @Paxxi @jimbob

Of all the things I would do in a posix terminal, cmd isn't one of them.

@penryu @Paxxi @jimbob

Sure, a whole posix shell environment would be fantastic, but this is still Windows and you still need to run the tools to manage the OS in something. Might as well not be the world's least useful terminal.

@dragonfrog @penryu @jimbob windows terminal + powershell is great
@dragonfrog @Paxxi @jimbob ngl all I really want is not to have to download putty as soon as I login
@penryu @Paxxi @jimbob Microsoft is still kind of passive-aggressive about making you jump through hoops to get WSL actually working. I forget what it is now, but I had to enable two subsystems in two different places to get it up.
@resuna @Paxxi @jimbob Reminds me of the Services for Unix package, which was apparently designed to drive MCP training.

@penryu @Paxxi @jimbob I kept running into Steve Walli at Usenix when he was working on Interix (later to become SFU), and at one I asked him when they were going to get bought by Microsoft and shelved. He said it was unlikely for legal reasons. Next year they had been bought by Microsoft and shelved. I asked him if he was lying when he said that and he asked "was it early or late in the convention?"...

Demand meant they had to bring it back but boy were they passive-aggressive about it.

@resuna @Paxxi @jimbob This sounds completely in line with my experiences. But I am amused at the full-circle.
@jimbob This is 100% valid. And while I do maintain an alias of scp='rsync $some_flags', I do not retain full knowledge of what $some_flags mean.
@jimbob Yeah but most of the time you just check the man page examples and copy the most basic one, just like everyone else. :]
@jimbob plus those extra 2 chars to type are a bridge too far for many
@jimbob it's like when your first learn a lot of Linux commands. I use ps aux due to muscle memory now. I've looked up the meaning of the letters a few times but never remember them. Rsync is avz my default for me now.
@justinz yeah ps aux is in my muscle-memory too!
@jimbob @justinz I spent a lot of time in the hard-core System V world so I also have "ps -ef" in my finger macros.

@jimbob Definitely true, but I still use it for big transfers because you can "easily" resume a transfer if it fails.

For rsync, compression is -z, tho I just have it in my muscle memory that "rsync" is always followed by "-avzP". :P

That enables compression and tries copying everything as is (think cp -a) while showing detailed progress info and enables resuming the transfer.

@jimbob rsync needs to die in a fire
@jimbob life changing knowledge
@jimbob I... also had no idea that such a flag existed!
@jimbob Good old Unix feature shyness. We can never have an improvement actually be the default! There might be a steam-powered minicomputer out there somewhere that will bust a leak if it ever sees an LZ code.
@WAHa_06x36 @jimbob ofc it can be *made* default
@jimbob rsync likewise. I was so sure rsync at least used compression by default!
@neia @jimbob This might make sense for rsync, as if you're copying between local file systems, all compression is doing is contributing a bit to global warming. Definitely makes sense that it would be default for scp though.
@vwbusguy @neia @jimbob wouldn't z just be ignored when doing local transfers?
@gerbrand @neia @jimbob How does rsync know they're local and not nfs, dav, cifs, iscsi mounts, etc?
@vwbusguy @neia @jimbob for rsync it'll be just like a local fs. The network communication is done by the file system driver so rsync can't influence that

@jimbob put the worms back in the can where they belong!

Um yeah, I think at one stage i learnt that, but I suspect it was forgotten amongst far too many other options and defaults

@jimbob Also scp is actually deprecated which keeps boggling my mind.
@hynek looks like— in RedHat at least— the scp protocol is deprecated but the command remains, now by default uses the sftp protocol under the hood https://www.redhat.com/en/blog/openssh-scp-deprecation-rhel-9-what-you-need-know
OpenSSH SCP deprecation in RHEL 9: What you need to know

One of the most important security changes for OpenSSH in Red Hat Enterprise Linux (RHEL) 9 is the deprecation of the SCP protocol. Here's everything you need to know.

@hynek @jimbob what is the source for this? What’s the “official” replacement? I would have assumed even rsync was built on scp

That said, I see no reason to use scp over rsync. Yes , I can never remember all the flags, but that’s what shell aliases are for, since you only need a small handful of combinations to do anything.

@tjc @hynek @jimbob The main reason I use scp over rsync is I can't magically wipe half the files in the source copy directory if I get the scp flags wrong.
@mtomczak @hynek @jimbob I agree that rsync can be dangerous. That’s why I heavily use shell aliases / functions (fish) for these. I only ever use a small combo of flags, so once I get those use cases I make functions with pre canned flags and some checks on slashes and whatnot. It’s a one time pain but then I never think about it again.
@tjc @hynek @jimbob I think that's good advice for interfacing with the command line in general.
@tjc @hynek @jimbob The scp command should still work in pretty much all instances, but the scp protocol has been replaced with SFTP in the backend.

@tjc @jimbob Here’s some details: https://lwn.net/Articles/835962/

Not sure at this point if the sftp-based scp that’s teased in the article and IIRC was linked in this thread is more of a stopgap or the new real thing. I personally prefer scp too because it’s just simpler and less dangerous to use.

Deprecating scp

The scp command, which uses the SSH protocol to copy files between machines, is deeply wired i [...]

LWN.net

@tjc @hynek @jimbob Scp relies on legacy protocols and lacks proper args sanitation.

New versions of scp have been updated to use sftp internally to avoid the security issues, so maybe safe to use depending on OS, but it’s safer just to always use rsync instead.

Here’s a summary from Redhat with more info and links. https://access.redhat.com/articles/5284081

SCP support in RHEL - Red Hat Customer Portal

OpenSSH’s SCP (secure copy, remote file copy program) is infamous for its security record over the last years. This article provides summary of recent vulnerabilities as a reasoning for definition of SCP support in RHEL.

Red Hat Customer Portal