31 ms·
Deprecating scp
- jonnypotty 6y agoThe solution can't be to fake scp over sftp. How does adding this confusing complexity help to make anything secure?
- enriquto 6y agoAs a unix purist, the "scp" program seems kludgy and in-elegant. We already have "cp" for copying files, why do we need another program? The appropriate thing to do is to mount the remote disk, and then use regular cp as God intended. Fortunately, this is possible today using "sshfs" (but there's still some ugliness in the fusermount implementation).
- rerx 6y agoOne could argue that this would be a bad abstraction because it hides the network layer.
- enriquto 6y agoOn the contrary. The only valid interfaces should be fopen, fread, fwrite and the like. The unix way is to mount the network as a filesystem cat /net/http/www.google.com this should render other tools like wget, curl, unnecessary.
- wahern 6y agoThat's the Plan 9 way. The "everything is a file" model mostly relates to exposing all objects as file descriptors that support read and write operations--specifically the read and write syscalls. IOW, everything is a file means the universal API for all objects[1] is read and write. How you acquire the descriptor is a fuzzy area. Using open on virtual namespaces makes alot of sense, but not always, and in any event no incarnation of Unix, not even Linux, supports virtual namespaces as comprehensively and seamlessly as Plan 9. [1] From a systems programming standpoint--kernel resources, IPC, etc. But there's an obvious relationship to, e.g., Smalltalk objects. (Just don't ask me what it is ;)
- enriquto 6y ago> Using open on virtual namespaces makes alot of sense, but not always Can you point to a specific and clear example of that "not always"?
- wahern 6y agoFor real unix purists user mounts don't exist. They were even removed from OpenBSD. Also, I'm pretty sure uucp predates VFS mounts over the network.
- enriquto 6y ago"pure unix" looks more like plan9 than openbsd
- tarruda 6y ago> If the remote server were to give a response like "here is the .bashrc file you asked for", though, scp would happily overwrite that file instead That really surprised me. I would have thought the implementaton would send a byte stream and that the client program would simply pipe that to the filename passed as first arg
- NickNameNick 6y agoBut you don't need to specify a filename, only a target directory.
- kgwgk 6y ago> the filename passed as first arg
- NickNameNick 6y agoReading comprehension issue on my part there, sorry. I should have specified glob expansion in the source part, which SCP needs to handle.
- SuperCuber 6y agoThe problem is that it supports several files per transaction, for example recursively copying a folder from remote to local - then only the remote actually knows the names of the files and it has to send them.
- steerablesafe 6y agoThat's not a problem when you actually ask for a directory of content. If you are trying to pull a single file and it results in an another file pulled and put next to it then it is certainly surprising.
- SuperCuber 6y agoYep, and I imagine that's roughly the fix they went for.
- tyingq 6y agoTar combined with ssh is a decent replacement for scp. A little more dangerous if you're in the wrong directory, etc, but... $ cd /source/dir && tar -cf - . | ssh rhost 'cd /dest/dir && tar -xvf -' Similar for the other direction.
- adrian_b 6y agoI prefer to use rsync over SSH as a replacement for scp: alias scp='/usr/bin/rsync --archive --xattrs --acls --progress --rsh="ssh"' I have completely deprecated for myself the use of both scp and sftp many years ago and I disable the sftp server (in sshd.conf) on all my servers. While scp and sftp are also slower, usually being unable to reach link speed on fast links, the main reason is that I have discovered that when copying files with them they sometimes were losing file metadata (e.g. parts of the timestamps or extended attributes) without any warnings or errors. rsync does not have such problems, it can make exact copies even when copying between different operating systems or different file systems. Because I have stopped using both scp and sftp many years ago, I do not know whether meanwhile there was any effort to remove the bugs from scp and sftp, but I doubt it.
- tyingq 6y agoI agree rsync is better than using tar, but often I'm using that ssh/tar command line before rsync is available on the other end.
- sildur 6y agoAh, the old "too many boring bugs, let's rewrite instead of fixing them (this time in rust!)" adagio.
- nix23 6y agoNo it's whe have already sftp wich is better and whe have unfixed bugs in scp so whe throw it out. >>The scp command is a historical protocol (called rcp) which relies upon that style of argument passing and encounters expansion problems. It has proven very difficult to add "security" to the scp model. All attempts to "detect" and "prevent" anomalous argument transfers stand a great chance of breaking existing workflows. Yes, we recognize it the situation sucks. But we don't want to break the easy patterns people use scp for, until there is a commonplace replacement
- deleted 6y ago[deleted]
- sildur 6y agoThat's not better.
- nix23 6y agoI see your totally not into "let's read the article first" thing.
- adrian_b 6y agoNo, "sildur" was correct that the "sftp" protocol is not better than the "scp" protocol. Another poster described in detail the problems with the "scp" and "sftp" protocols. They have different advantages and disadvantages and neither of them can be considered a good file copy protocol.
- nix23 6y ago>It has proven very difficult to add "security" to the scp model. >>Compared to the SCP protocol, which only allows file transfers, the SFTP protocol allows for a range of operations on remote files which make it more like a remote file system protocol. https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol If you want the best "JUST File-transfer prog" use nc or rsync over ssh
- jart 6y agoJonathan Corbet should clarify what he means when he says "the openssh community" considers scp deprecated because it sounds like he's only speaking for himself. It's kind of clickbaity. Although his technical research is stronger than the CVEs he's citing. CVE-2020-15778 is a particularly noisy one since the author likely hadn't considered rssh shell and should have clarified exactly which configuration options he felt were compromised.
- quietbritishjim 6y ago> than Corbet should clarify what he means when he says "the openssh community" considers scp deprecated because it sounds like he's only speaking for himself. Jonathan Corbet is an employee of LWN, which produces news on a variety of Linux topics, funded by paid subscribers (like me). As far as I know he's not a contributer to OpenSSH any more than he is to any other project he reports about, unless you know something specific? Or are you mixing this up with someone's personal blog?
- jart 6y agoHe's not just an employee but their editor. A journalist who's smart enough to write kernel drivers should have been smart enough to get someone from the OpenSSH team to go on record or linked to one of their announcements. Because they actually do speak for their community. LWN comes across as promoting their own views.
- pseudalopex 6y agoHe quoted them calling it historical.
- jart 6y agoWho's them? So I did some digging on my own and I managed to uncover this statement from Theo de Raadt: commit 82ff5eac51d41356a89ceffe2102c69616946320 Author: deraadt <deraadt@openbsd.org> Date: Sat Oct 3 02:18:33 2020 +0000 split introductory paragraph, and insert ominous words about the glob issue, which cannot be fully fixed and really requires completely replacing scp with a completely different subsystem. team effort to find the right words.. Why doesn't the LWN article talk about that? It sounds like this glob thing is the real deal-breaker for the OpenSSH team.
- voiper1 6y agoI use rsync whenever I can, I only used scp on my windows machine because I didn't have a working rsync. Now using croc for single file moves/copy... have to be installed and logged into both sides, but I don't have to copy/paste the entire paths.
- anilakar 6y agoMost people use scp and not sftp because they prefer the cp-like semantics of the command line tool. I have no idea why OpenSSH's scp does not use SFTP by default and allow an explicit fallback to scp for those systems that don't have the SFTP subsystem enabled.
- fanf2 6y agoPuTTY’s pscp program works in the sensible way you suggest https://the.earth.li/~sgtatham/putty/0.74/htmldoc/Chapter5.html#i29 https://the.earth.li/~sgtatham/putty/0.74/htmldoc/Chapter5.h...
- chasil 6y agoAlso, putty is available in EPEL for the CentOS crowd. # cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.9 (Maipo) # pscp PuTTY Secure Copy client Release 0.73 ... -sftp force use of SFTP protocol -scp force use of SCP protocol It looks like it has a LOT less library dependencies than scp: $ ldd /bin/pscp linux-vdso.so.1 => (0x00007ffd79be1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f04c91bf000) libc.so.6 => /lib64/libc.so.6 (0x00007f04c8df1000) /lib64/ld-linux-x86-64.so.2 (0x00007f04c93c3000) $ ldd /bin/scp | wc -l 31
- jedisct1 6y agoEven though Piknik has mostly replaced scp for me, scp is here to stay. It remains the easiest way to transfer things between trusted machines that you already have ssh access to.
- deleted 6y ago[deleted]
- sanxiyn 6y agoEh, scp-the-command (interface) may be here to stay, but scp-the-protocol (implementation) is definitely due for replacement. Under the proposed change, scp will remain the easiest way to transfer files for you. It will just no longer use outdated scp protocol and will use sftp protocol instead.
- snoshy 6y agoThis an extremely terse and pointed article about the present day reality of a command that users generally take for granted or avoid altogether. LWN rarely disappoints, but scp is an obvious next step for beginners upon learning about SSH access, and it's really great to provide context around what is actually happening with it in a manner that actually might be in reach of understanding for beginners.
- pengaru 6y agoI've been living with this for nearly a year now: alias scp='rsync --verbose --progress --partial' Since my decades-old scp habit isn't changing anytime soon, and it hasn't shown to be a problem yet - with the added bonus of resuming partial copies.
- ekianjo 6y agoInteresting, is there any catch in doing that or does it work in most use cases?
- ur-whale 6y agovery different behavior when it comes to interpreting trailing slashes in directory names.
- gjvc 6y agorsync-pro-tip: use a trailing slash on both the source/ and the target/ and you'll never go wrong
- kzrdude 6y agoWhat goes wrong if I don't do that?
- masklinn 6y agoThe trailing slash on the source expresses that you want to copy the contents of the source in the dest, otherwise you’ll copy the source itself (creating a subdirectory).
- jjice 6y agoI believe if you don't use a slash at the end of the source directory, it will copy the _directory_, not just its contents. rsync code remote:/ I believe that results in remote:/code/app.js rsync code/ remote:/ I believe that results in remote:/app.js
- perryizgr8 6y agoI use scp over sftp because sftp requires setting up an additional sftp server. I just want to copy files, given that I have ssh access. As for rsync, I always thought it was used for backup and something that would run in the background, not routine single file/directory copying.
- pseudalopex 6y agoOpenSSH requires 1 line in sshd_config. What distribution enables SSH without SFTP?
- _ph_ 6y agoThe nice thing about scp is, it works with any ssh server. The machine you want to scp to might not run OpenSSH, you do not know whether SFTP was configured on it. If it is not active in the default configuration, a lot of machines won't have it activated.
- pseudalopex 6y agoThey made it sound like SFTP always requires an additional server. Does any non embedded distribution enable SSH without enabling SFTP?
- tjpnz 6y ago>Perhaps one more piece of 1980s legacy can finally be left behind. I didn't realise scp was that old.
- dredmorbius 6y agoSSH (and scp) are not. The protocol scp is based on, in command and file semantics, rcp, is. It's part of the Berkeley r-command suite, released in 1982. https://en.wikipedia.org/wiki/Berkeley_r-commands https://en.wikipedia.org/wiki/Berkeley_r-commands
- ur-whale 6y agoThey might be talking about the protocol used by scp which is rcp and is indeed that old.
- josefx 6y agoThe author is even older, making his opinion a 1970s legacy. Can't wait until we get rid of wheels, roads or even sliced bread. All that legacy stuff is only holding us back.
- mattmanser 6y agoWhat's with the casual ageism? Are you superior because you have less knowledge and experience than the author?
- marcosdumay 6y agoYou may have missed a couple of jokes.
- josefx 6y agoIt is a sarcastic reference to the authors closing sentence. Hence my second sentence pointing out other old things to get rid of.
- mattmanser 6y ago
- ur-whale 6y ago'rsync is a capable alternative' except for the fact that rsync has a very weird (to me) behavior with regards to trailing slashes in copying directories. most definitely not a drop-in replacement for scp
- voiper1 6y agoargh trailing slashes can be a pain! I've had to delete/move many times due to differences in trailing slashes.
- adrian_b 6y agoYou are right, but the rsync behavior has good reasons, explained in its man page. Moreover, all UNIX commands have different behavior depending on whether you write or not trailing slashes, at least when the arguments happen to be symbolic links. To avoid mistakes due to the different behaviors, I use for cp and mv aliases that include the option "--strip-trailing-slashes".
- xorcist 6y agoThat's a problem with scp, not with rsync. rsync dir_a server:dir_b Will there be a directory called dir_a on the server? Well, that depends on if dir_b exists. Run the command again and the result may be different. That's not acceptable behaviour for a tool keep a remote directory synced.
- deleted 6y ago[deleted]
- alias_neo 6y agoFrom someone who knows nothing about the semantics of what and why, how is this deprecated without a replacement? rsync is not a replacement, sftp is not a replacement. If I can't use cp like syntax, it's not a replacement. I use scp almost daily to copy things to/from/between remote machines, the syntax is quick and easy. If the issue is with the protocol, why is the protocol not being fixed or updated while continuing to support the syntax?
- ratherbefuddled 6y agoThe replacement proposed in the article is an scp implementation with sftp used as the underlying protocol.
- toyg 6y agoSFTP has to be set up on the remote server though. Scp does not.
- EQYV 6y agoThis is my main concern as well.
- Filligree 6y agoDoes it? I've never done so, and it's worked fine on every server I've ever built. It's at least enabled by default, I guess.
- 3np 6y agoYou need the sftp subsystem enabled on the server, which may be disabled on the server side (not that uncommon). The current scp still works fine in that scenario.
- tinus_hn 6y agoIf the scp binary is available on the server side. The point is moot though because disabling the sftp subsystem yet granting people shell access is backwards.
- pw6hv 6y agoIANAL and therefore I would be interested to understand why GPLv3 would be a deterrent for using rsync. Could anyone ELI5?
- ComputerGuru 6y agoIt won’t ship with GPLv2 or BSD distros/OSes.
- unixhero 6y agoWhy do I want this? I rather enjoy scp using native SSH.
- siwatanejo 6y agowhat do you mean?
- throwaway4good 6y agoSounds a bad idea; scp has some gotchas but it is used by a lot of people who has gotten used to the way it works.
- rob74 6y agoSome of the examples are indicative of the time this article was written: scp election-predictions.txt dumpster:junk/
- keeperofdakeys 6y agoAnd unfortunately there are some devices out there that still require scp with no sftp support (copying files to a cisco switch for example). You can also use tftp or ftp, but it's not as handy.
- ZoomZoomZoom 6y agoHere may be the right place to ask: How do you browse for scp? I rarely can remember the full path to the file I need so I end up with two terminals: one for ssh browsing and one for copying with scp/rsync. I feel I'm doing something wrong here.
- Lex-2008 6y agoI do pretty much the same, although in single terminal: `pwd` and `ls` on remote machine to print dir and file name, then exit ssh and edit recent ssh command to pull the file copypasting recent `pwd` and `ls` output. Luckily, I have to do it very rarely. When doing some more serious file-shuffling - I resort to graphical file managers. Which is, well, even worse than two terminals in this regard :)
- moonshinefe 6y agoMight just be easier to use sftp then depending what options you need. You can ls and get/put files from a command prompt like interface and it uses the ssh protocol as well.
- acdha 6y agoEnable OpenSSH’s control master feature to reuse connections and it’s fast enough to use tab completion.
- voqv 6y agoYou can have tab autocomplete working if you're using ssh keys and you have their passphrases unlocked with a keychain/ssh-agent.
- Timpy 6y agoI spend my entire work day in the terminal so remembering the full paths of things has become second nature without much effort. If you just drop into the terminal occasionally for file transfers then there's nothing wrong with opening a second terminal to get the paths you want.
- deleted 6y ago[deleted]
- dredmorbius 6y agoWhat if any effect does this have on SSH based transports such as sshfs?
- pseudalopex 6y agoNone. sshfs uses SFTP.
- dredmorbius 6y agoThanks.
- butlersean 6y agohow will the earth be protected from the keiter anomalies?
- ChrisMarshallNY 6y agoWhenever I see "SFTP," I remember this: https://en.wikipedia.org/wiki/File_Transfer_Protocol#Simple_File_Transfer_Protocol https://en.wikipedia.org/wiki/File_Transfer_Protocol#Simple_... I think that protocol is long in the grave, but its acronym still resonates in my head.
- dec0dedab0de 6y agoIt turns out, though, that in some situations, especially those where there is little or no trust between the two ends of the connection, the actual level of security may be less than expected. So maybe we just need to educate people that giving someone scp access is the same thing as giving them ssh access? not that many people even use SCP to begin with, maybe a warning in the config file if someone tries to only enable scp without ssh. Why would you even do that?
- banthar 6y agoThe problem with scp is that the trust also needs to go the other way. There is a lot of ways ssh server can trick the client into doing bad things on your local machine.
- dec0dedab0de 6y agoThat's not mentioned in the article, do you know if it is worse than just normal ssh?
- banthar 6y agoFirst issue mentioned: CVE-2019-6111 is an example of such attack.
- eptcyka 6y agoI really want a way to expose filesystem contents to someone via SSH without giving them the ability to execute arbitrary code. Bonus points for confining access to specific directories.
- pseudalopex 6y agoWhy not SFTP?
- kevinoid 6y agohttps://github.com/scponly/scponly https://github.com/scponly/scponly can be used to prevent command execution and supports chroot. It avoids the server-side scp protocol security issues by rejecting shell metacharacters in commands. It also supports sftp. If you don't need scp, you could force the use of internal-sftp <https://serverfault.com/a/354618 https://serverfault.com/a/354618>.
- LinuxBender 6y agoSFTP chroot solves that. You can use the lftp client with the sftp and mirror subsystem to replicate the behavior of rsync. [1] [1] - https://serverfault.com/questions/836103/replace-scp-with-sftp/836136#836136 https://serverfault.com/questions/836103/replace-scp-with-sf...
- loloquwowndueo 6y agoThe -3 option is crucial for some of the processes where I use scp. I will have to explicitly download then upload from the intermediary system without -3 and that’s extra work I’d rather not do :)
- known 6y ago"The best way to escape from a problem is to solve it" --Alan Saporta
- ezekiel68 6y agoI don't appreciate either phoronix or lwn using this clickbait-ey title. The scp command line program isn't going anywhere and (as I understand it) the usual options will remain the same. The news story is about the protocol that runs behind the command.
- deleted 6y ago[deleted]
- lcall 6y agoI use OpenBSD (they are the maintainers of OpenSSH which provides scp), and watch one of its mailing lists, and it seems like they are encouraging disuse of scp for security reasons as mentioned elsewhere here. The Fedora-related discussion here of a new scp that uses sftp underneath, I'm guessing is less likely to make it to OpenBSD soon, for whatever such a rough guess is worth. I made a separate comment suggesting a way to locally replace scp with sftp, as others have also done with rsync (Ctrl-F here for "progress").
- protomyth 6y agoThere is a new version of rsync in OpenBSD 6.5+ https://man.openbsd.org/openrsync https://man.openbsd.org/openrsync with the normal OpenBSD license.
- jbirer 6y agoI use SCP all the time to transfer files to a VPS. I do not understand this trend of deprecating things that are working (X.org, SCP) with inferior alternatives (wayland, ssh cat etc).
- pmlnr 6y agoYou didn't read the article, just the title, did you?
- pdonis 6y agoBy "deprecate" the article actually means "replace with a wrapper around sftp that has the same basic command line interface as the current scp". Since sftp works just fine but has a lousy command line interface (as the article notes), this would not be an example of the trend you describe.
- chias 6y agoIn fairness, deprecating a Linux CLI program basically amounts to a tentative suggestion that you maybe try to find an alternative sometime in the next 20-30 years.
- aneutron 6y agoThe amount of times the "-3" scp flag saved me from waiting tens of minutes is non-negligeable. I'd say it's paramount to a number of premade scripts out there, so an "scp replacement" without it is bound to make me sad and probably break some stuff
- zestyping 6y agoWhat does that flag do?
- bertman 6y agoFrom man scp: -3 Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option disables the progress meter and selects batch mode for the second host, since scp cannot ask for passwords or passphrases for both hosts.
- noobermin 6y ago> Even if it is a bit slower, a version of scp that avoids the security problems with the current implementation while not breaking existing scripts (and set-in-their-ways users) seems like a welcome change. How much slower are we talking?
- SoSoRoCoCo 6y agoThe problems outlined by the article do not at all seem significant enough to merit a full scale deprecation of scp. The article states that beside file duplication on the source machine, the only security issue is the same as having any SSH access on the machine. The other issue (the bashrc example) is akin to a bonehead move like accidentally typing rm -rf somewhere important. `scp` doesn't need a gun lock, IMHO, just an attentive user, like any command, really. This comment made me chuckle: > Then, there is the simple matter that scp is ingrained so deeply into the muscle memory of so many users. As with other deprecated commands (ifconfig, say), it can be hard to make the switch. Trying to wean myself off ifconfig to ip & netplan has been effing brutal since network provisioning is something I do less than once a quarter. Similarly, I've been trying to 'train' myself to use rsync since ... checks notes ... ~2004, and I still have to stop, clear my head, and read the man page to figure it out because it is useful for huge transfers, but those are so rare in my flow.
- Spivak 6y agoDon't you bring netplan into this! The ifconfig -> ip transition is at least an improvement. Canonical had every chance to use NetworkManager which is battle-tested, has an extremely polished language bindings, a cli, tui and multiple GUIs, handles complex configurations like a champ, has a nice connection plug-in system to handle all kinds of less common stuff like VPNs, Bluetooth, Wi-Fi sharing, IPoDNS and a plug-in system to support reading configs in other formats (like maybe YAML for instance). The plug-in ifcfg-rh is the reason why ifcfg scripts all still work. But no, they wrote this entirely non-extensible basically trivial C utility (that's not a dig, seriously look at the code, it does almost nothing!) that doesn't reduce complexity at all since it's the thinnest possible abstraction over its backends and adds yet another layer of things that might fail. But it's integrated into cloud-init by default so it's easier to just slog though fighting it than to rip it out.
- reader_1000 6y ago> The other issue (the bashrc example) is akin to a bonehead move like accidentally typing rm -rf somewhere important. I think you've misunderstood the issue a little bit. Dangerous command is this: scp admin:boring-spreadsheet.ods . Here, user do not do type anything wrong, however if an attacker somehow replaces the remote with a malicious ssh server which returns a .bashrc that contains dangerous content (such as aliases like alias ls=rm -rf *) then you are basically screwed. So this is a serious issue. Other security error is quite interesting if I understood it correctly (scp some-local-file remote:'`touch you-lose`remote-file'). It is basically running the command in the remote server. If that is so, why would a file transfer protocol run a command in the remote server? If an attacker manages to put a file with name `rm -rf /` in the directory that one is going to transfer, it may damage the remote system. I think, this part of protocol really needs to be fixed.
- coliveira 6y agoIf someone has file transfer access to a server, the same outcome can happen, only in a perhaps more contrived way. I don't think this is a problem with scp itself. There should be a more restricted transfer command that disables these options however, for the cases where the extra security is necessary.
- deleted 6y ago[deleted]
- ChuckMcM 6y agoI may be a curmudgeon here on this one but I read that and thought it read like "Chainsaws can cut you so we are going to start recommending only plastic teeth on chainsaw blades." Sure, if you're on an appliance delivery vehicle instead of a computer, by all means cut off all the ways it could be screwed up by either an ignorant user or a malicious actor, but if its a computer? Why not deprecate gcc? After all you can compile code with security holes galore with that bad boy, where will it end? Only type safe vendor supplied library languages for you from here on out danger cowboy. Okay enough rantings.
- teknopaul 6y agorant on, rant on, I fully agree. You can do nothing dangerous with scp you can't do with ssh. If you want one way uploads from untrusted locations use HTTP like everybody else. scp works. Don't break it.
- lcall 6y agoFWIW here is how I replaced scp commands in my scripts with sftp. (If there is a better way of course I am interested.) OLD: scp $FILE "$USER_AT_HOST:/home/username/dir1/" NEW (a single embedded newline or Enter right after the word "progress" seemed required, though not correctly displayed here, to enable a visual progress indicator; maybe some kind of \n could work instead but didn't immediately for me and this was easy enough in the end): echo "progress put $FILE"|sftp -f -p -N -b - "$USER_AT_HOST:/home/username/dir1/" OR (single line, without progress indicator): echo "put $FILE"|nice sftp -f -p -N -b - "$USER_AT_HOST:/home/username/dir1/" Edit: I suppose this could be carefully put in a script called "scp" that takes parameters, or aliased, something like others here have done with rsync options (^F here for the word "progress" to see some).
- lcall 6y agops: FWIW, I made a script and the line with "progress" works on a single line now, not sure what I was doing wrong before. My contact info is in the footer of the web site noted in my profile, if it sounds useful. But the main line is something like this: echo -e "progress\n put $1"|sftp -CfpN -b - "$2" Or, to be able to echo it first for confirmation (bash, typed/untested largely from memory not the actual script but close): #!/usr/bin/env bash set -eu; set -o pipefail if [[ #$ -ne 2 ]]; then echo "2 parameters expected"; exit 1; fi CMD="echo -e \"progress\n put $1\"|sftp -CfpN -b - \"$2\"" echo "Do this (Enter to continue)?: $CMD";read bash -c "$CMD"; echo "Result: $?"
- er4hn 6y agoBack when CVE-2020-15778 came out, there was an ongoing thread on openssh-unix-dev@ about deprecating scp. The main problem that I noticed from the dialogue was that the community felt (paraphrasing and summarizing) that "If you support scp on your server, you should know to filter backticks." There was little interest in changing the behavior (understandable - this breaks backwards compatibility) nor in updating the man pages and other documentation to note this was an issue. I felt that the latter was where scp showed its legacy. Security should be built into products by default, not a series of "gotchas" that users manually configure against. I love the idea of having a 'secure with default settings' version of scp that functions with the same syntax. I think that would be great to get users to use by default and avoid the footguns that comes with default scp.
- iaabtpbtpnn 6y agoI do not care about any of the issues raised in this article, and I plan to continue using scp exactly as I have been for decades without problems.
- mcguire 6y ago$ scp some-local-file remote:'`touch you-lose`remote-file' "This will result in the creation of two files on the remote system: the expected remote-file and an empty file called you-lose. Adding more interesting contents to that file is left as an exercise for the reader." The hell?!? 1. Why is scp running shell commands? 2. How is this a problem with the protocol?
- jolmg 6y agoI see there's no discussion on the loss of being able to select files using server-side state. The SCP protocol is like the only tool that allows that (ignoring being able to use a contrived combination of ssh and tar). For example, very often I use this to pull the latest file I produced in a server that has zsh set as the shell: scp -T trustedserver:'*(oc[1])' . I just pull that command from my history. For the other trusted servers that don't have zsh, I do the following (while being completely sure that the filenames I'm working with aren't directories, don't have newlines, spaces or other shenanigans): scp -T trustedserver:'$(ls -t * | head -1)' . If SCP protocol support is completely dropped, the only alternative I know of would be something like this: ssh trustedserver 'tar c *(oc[1])' | tar x ssh trustedserver 'tar c $(ls -t * | head -1)' | tar x That wouldn't show per-file download progress bars, but oh well...
- robarr 6y agoThe following subscription-only content has been made available to you by an LWN subscriber. Thanks !
- rurban 6y agoThe PR is at https://github.com/openssh/openssh-portable/pull/194 https://github.com/openssh/openssh-portable/pull/194 Looks surprisingly easy enough.
- mcstafford 6y agoI suppose this could be easily worked around with an alias presuming the most frequent use case names only files. alias scp='rsync'