64

I have over 20 years experience in Un*x, and I have been using scp for immemorial times. scpis over SSH, therefore I consider it as secure as the latter. Now, in my company, where I recently took up a job, the Security Officer says that scp should not be used, because it is unsafe and obsolete. sftp should be favoured over it (yet over SSH too...)

I don't immediately agree with this, based on the infrastructure underneath scp, and based on how popular and trusted scp is in the professional community, and among my other colleagues from my ex-companies. I don't want to change my mind just because some CSO said it.

  • This said, is there here a subject?
  • Is scp suddenly the blacksheep?
  • Is is just a mere security expert debates in higher spheres?
  • Or is scp just good to use?
Jonathan Leffler
  • 1,479
  • 13
  • 14
Fabien Haddadi
  • 799
  • 1
  • 5
  • 10
  • 32
    They are probably referring the what was written in the release announcement for OpenSSH 8.0 when [CVE-2019-6111](https://www.cvedetails.com/cve/CVE-2019-6111/) was fixed in `scp`: "The scp protocol is outdated, inflexible and not readily fixed. We recommend the use of more modern protocols like sftp and rsync for file transfer instead." https://www.openssh.com/txt/release-8.0 I'm not writing this as an answer as I can't say anything useful about the technical bits or the implications. – Kusalananda Mar 05 '20 at 12:40
  • 2
    It also depends whether you/they mean SCP and SFTP protocols in general, or `scp` and `sftp` clients from OpenSSH package. – Martin Prikryl Mar 05 '20 at 13:20
  • 8
    Both scp and sftp work over a ssh channel, so they're just as secure as the ssh channel (in fact, both could be made to work over any reliable channel, but they're usually run over ssh). Neither of them is making the security of the channel or of the ssh infrastructure stronger or weaker. All the security theater is about someone connecting to a rogue server via scp, and the server being able to overwrite some of user's files if they used a glob (eg. `scp foo:dir/*.txt ~` resulting in `.bashrc` being overwritten). –  Mar 05 '20 at 13:26
  • 1
    Notice that the "fix" for CVE-2019-6111 doesn't have any effect when `-r` is used, so it's mostly a feel-good change. –  Mar 05 '20 at 13:26
  • I did make a mistake. I meant sftp is built on ssh. And I still stand by my comments. It has been corrected and some links to prove my point. – Mark Stewart Mar 05 '20 at 21:22
  • @CharlesDuffy could you please give some example of incompatible scp implementation? AFAIK, they're all derived from the one from the ssh source code (even that distributed with dropbear). As to "ad-hoc mess", one man's mess is another man's lightweight hack. And ssh itself would qualify: it doesn't even support properly passing command line arguments around. –  Mar 06 '20 at 07:42
  • @mosvy, my understanding (on which I'm open to correction) was that the original commercial scp implementation was incompatible with the openssh one. – Charles Duffy Mar 06 '20 at 13:14
  • 12
    Depends which one. SCP-173 is very unsafe. SCP-294 seems to be pretty safe if used correctly. – user253751 Mar 06 '20 at 14:32
  • 1
    @CharlesDuffy a link would be great. This is not rhetorical -- it may help me improve my scp protocol [outline](https://unix.stackexchange.com/a/539439/308316). –  Mar 06 '20 at 16:20
  • 1
    @bobsburner I don't get your point. You can already overwrite your `~/.ssh/authorized_keys` via scp. The check only kicks in when you're copying from the remove to the local machine and are using a glob pattern which is expanded by the remote machine. The remote machine could send you something completely unexpected: eg. you asked for `*.txt`, but they may send you `.bashrc` instead, and the local client used to trust the file names sent by the remote, and dutifully overwrite it. –  Mar 06 '20 at 16:26
  • 1
    @bobsburner That's why the local client now checks the files sent by the remote against the glob (with an adhoc pattern matching implementation LOL) -- but that is very kludgy, because the shell on the remote machine may use a different glob syntax, you may want to quote or escape parts of the file name, etc. –  Mar 06 '20 at 16:29
  • @mosvy, as I'm unable to find support for my claim, I'm going to need to withdraw it. (We're in "hazy memories of discussions ~20 years ago" territory). – Charles Duffy Mar 06 '20 at 16:54
  • 1
    Look at Stack Exchange, marking my clearly off-topic joke comment as useful instead of deleting it. – user253751 Mar 06 '20 at 17:48
  • @user253751 (11 months later...sry) 10 votes? Given that I read right past it and didn't make the connection until your last comment...the foundation is a lot more popular/mainstream than I realized. – B Layer Feb 06 '21 at 18:13

6 Answers6

41

It's marginally "unsafe"

It was marginally "unsafe" before the addition of scp -T in OpenSSH 8.0 and it still is marginally "unsafe" when using scp -r.

Like other answers have stated, claims that scp is unsafe come from the client's previous inability to verify that it's receiving what it requested. The reason why scp couldn't verify is because the request is made using shell code running in the server's environment (with the server's state).

For example, let's say that the server's shell is set to zsh with extended glob, and I have my project directories set as zsh dynamic named directories for quick access. If I want to get a file from Rails project foo, I could get it with:

scp server:~foo/config/database.yml .

zsh on my server expands ~foo to ~/work-for/client/$client_name/foo.

If I want to get the server's 10 newest regular files, I could do:

scp server:'*(.oc[1,10])' .

If the server has plain bash, I could do:

scp server:'$(ls -t | head -10)' .

If I wanted to get the files that contained a pattern foo in their content, I could do:

scp server:'$(grep -l foo *)' .

There's just no way for the scp client to verify these kinds of requests that use shell code. However, it is a concern that it enables a malicious server to respond to:

scp -r server:foo/ ~

with overwriting .ssh/authorized_keys. In the eyes of scp, foo/ is server shell code that will evaluate to who knows what.

Enter scp -T:

-T Disable strict filename checking. By default when copying files from a remote host to a local directory scp checks that the received filenames match those requested on the command-line to prevent the remote end from sending unexpected or unwanted files. Because of differences in how various operating systems and shells interpret filename wildcards, these checks may cause wanted files to be rejected. This option disables these checks at the expense of fully trusting that the server will not send unexpected filenames.

To summarize, the previous default behavior of scp was moved to -T, and now the default is to check what's being received, using the provided argument as a simple pattern, when one's not doing a recursive copy. I believe it recognizes simple globs and escapes (looking at the source, it uses fnmatch(3) for the matching, with flags set to 0). In other words, it behaves more predictably when you're not looking to take advantage of its unique ability to specify files by shell code.

So now, if you don't use -T and you don't use -r, the only way to overwrite stuff like .bashrc is to ask for it explicitly. If you want to use shell code, you'd have to use -T at the expense of trusting the server:

scp -T server:'*(.oc[1,10])' .

So now you get the safety in the simple, non-recursive cases without completely giving up the unique ability that makes scp more useful than other utilities like sftp or rsync.

Can scp be replaced by sftp?

sftp can't specify the files it wants with shell code. It only accepts actual file paths. It's more limited that way. If you only needed scp for simple filepaths, then yes. However, if you want the added power of being able to specify the files from a simple command with server-side shell code (albeit at the expense of having to trust your server), then I think your only choice is scp.

Why the quotes around "unsafe"?

It was unsafe, but only when you wouldn't trust the server to not be compromised. In my case, and perhaps for the majority of people, we use scp with servers that we completely trust in other ways anyways. In particular, I use it to login from my laptop to my desktop or vice versa. If we can't trust our own devices, then what can we trust? That's why I think calling it just plain unsafe is hyperbolic. It's not comparable to how we call telnet unsafe, for instance.

I still appreciate the change to requiring -T, though. It is safer. Also, it's certainly true that for those people that don't need the features enabled by -T, there really isn't much advantage in using scp over sftp or rsync.

JoL
  • 4,520
  • 15
  • 35
  • @mosvy I thought I had tried it before, but I guess not. I've deleted the mention of quoting support. Do you have any source on `-r` turning off the filename check? That's something that's not as simple to check as the quoting thing. I can't see why support for `-r` filename checking couldn't have been added either. – JoL Mar 07 '20 at 08:30
  • @mosvy Nevermind. I can confirm by seeing that it lets me use extended glob on files when using `-r`. I still wonder why `-r` couldn't be supported. – JoL Mar 07 '20 at 08:48
  • You can check my demo -- you can modify the perl script to experiment with different behaviours from an assumed rogue remote scp. As to `-r`, I couldn't figure out any way the file checking could be supported with `-r` (and apparently, neither the openssh devs did). Of course, they could've added an extra option to set a pattern of accepted paths (_independent_ of the pattern used for the source argument, and of the other arguments used with scp). But they did not. –  Mar 07 '20 at 09:36
  • 1
    @mosvy What do you mean a pattern independent of the source argument? Why wouldn't the source argument work as the pattern? If the pattern is `foo/`, couldn't scp match the name of the received directory and accept all files that go under it on match? – JoL Mar 07 '20 at 09:41
  • Add a `-G 'foo/*/bar.txt'` option which will simply reject any filenames which would not match that pattern when created _at the destination_ (on the local machine), no matter what the other arguments are, and what pattern you use for the source. _That_ would've been an improvement. –  Mar 07 '20 at 09:45
  • @mosvy It may be useful, but it's extraneous to the subject. If `scp -r server:foo/ ~` resulted in scp receiving a directory `foo/` which it matches against the source argument pattern `foo/`, and then receives files `foo/f` and `foo/g`, it could simply accept them for having previously matched the directory `foo/`. The point of this filename checking is that when asking for a recursive copy of `foo/` the client should accept `foo/` but not something else like `.ssh/`. Being able to filter stuff inside is completely extra, and apart from the issue. – JoL Mar 07 '20 at 09:53
  • How is it extraneous to the subject? The "insecurity" of scp (the subject of this Q) is that the server could overwrite files on the local machine. That would prevent it. As to your idea, try writing a patch. –  Mar 07 '20 at 10:17
  • @mosvy One of the main points of scp is to overwrite files on the local machine. I think you stated that too generically. I don't think the insecurity of scp includes that on a command `scp -r server:foo/ ~` scp would overwrite things inside `foo` different from `foo/*/bar.txt`. It's ok for it to take all of `foo/` just like `cp` would do. I don't think anyone would expect anything different. The problem is with that command copying things into `~` different from `foo/`, which would be unintuitive/unexpected. – JoL Mar 07 '20 at 16:12
  • @mosvy I *was* trying to write a patch yesterday, but I still haven't completely understood the flow of things. In particular, [`-T` only seems to affect brace expansion](https://github.com/openssh/openssh-portable/blob/3bf2a6ac791d64046a537335a0f1d5e43579c5ad/scp.c#L1271), which doesn't make any sense. – JoL Mar 07 '20 at 16:18
  • Of course that was meant "overwrite files, other than those asked for". The fix they have added to scp only checks _filenames_ not _paths_. As I already said, you could try something different. I would not encourage you to spend time on, though. –  Mar 07 '20 at 16:18
  • 1
    It's `brace_expand` which generates the list of patterns the file names will matched against. If there are no patterns, no check will be done. –  Mar 07 '20 at 16:22
  • 2
    TL;DR: If you do not trust your server, verify that your `scp` client has support for the `-T` flag but **use neither** `-T` nor `-r`. – August Janse Dec 03 '21 at 10:15
22

The way I read it is, "it depends".

According to CVE-2019-6111

However, the scp client only performs cursory validation of the object name returned (only directory traversal attacks are prevented). A malicious scp server (or Man-in-The-Middle attacker) can overwrite arbitrary files in the scp client target directory. If recursive operation (-r) is performed, the server can manipulate subdirectories as well (for example, to overwrite the .ssh/authorized_keys file).

So if scp goes between hosts on your premises (datacenter), it is likely (but not certain) than no MITM attack can be performed.

However, if you fetch business files from a customer/partner over the world wild web, you should rely on sftp, or better, ftps. (At least, ensure that the scp client and ssh server have proper versions)

Archemar
  • 31,183
  • 18
  • 69
  • 104
  • 1
    "or better ftps" - It's kind of peripheral to the question, but if your suggesting ftps is better, it might be worth a brief mention of why (and/or link explaining it). – Ian D. Scott Mar 05 '20 at 23:58
  • 6
    I would not consider ftps to be better. I would trust ssh over ssl/tls considering the history of vulnerabilities between the two – slebetman Mar 06 '20 at 00:20
  • 1
    @slebetman Why? SSH doesn't have a widely used mechanism of key trust. TLS does (namely, Certificate Authorities, who are audited by companies who develop operating systems and browsers that contain lists of trusted CAs). With SSH, most people just blindly type "y" when connecting to a new system. – Greg Schmit Mar 06 '20 at 03:19
  • 7
    . . . but that CVE has been fixed. If your premise is that we should act as though all past security issues are still in effect, then I don't see how you can recommend any other software, either. (Are you really saying that `sftp` and `ftps` have never had any potential security issues?) – ruakh Mar 06 '20 at 04:36
  • @GregSchmit As I mentioned, based on the history of bugs found in both the protocols themselves and implementations of protocols (BEAST, CRIME etc.). SSH has had far fewer specification mistakes mainly due to the different cultures surrounding their development. SSL/TLS was developed as a solution to a business requirement of websites while SSH was developed as a solution to a technical requirement of sysadmins. – slebetman Mar 06 '20 at 05:16
  • @GregSchmit I would definitely NOT trust telnet-over-tls to access my servers. I'd rather stick with ssh – slebetman Mar 06 '20 at 05:17
  • 4
    @slebetman History of bugs is a red herring. In many cases, more bugs are found in a particular protocol or system because it's a larger target because it's used more and gets them identified more often. You didn't address my main point, which is that in SSH, most people use it and blindly type "y" the first time they SSH into systems across the WAN without checking the fingerprint. TLS has an infrastructure of checking certificates automatically, which improves security. – Greg Schmit Mar 06 '20 at 06:12
  • 3
    @slebetman It's precisely because SSH was developed for sysadmins that it wasn't hardened against human error in the way that TLS was. And sysadmins make human errors (like blindly typing "y" when prompted to check the key fingerprint) **all the time**. – Greg Schmit Mar 06 '20 at 06:14
  • Certificate checking is not to be completely trusted. You can trust it up to the level of small-time hackers but when we go up to the level of state actors we know the US government, Iran, China (and for a while, the Italian government) have managed to obtain certificates by merely asking issuers to issue it for them. I don't doubt that other well organized efforts can also obtain certificates. I put my trust in it at the same level of SSH fingerprinting – slebetman Mar 06 '20 at 06:40
  • @GregSchmit Also note that it's false that TLS had a larger footprint. The bugs that were discovered were mostly discovered by security researchers and a lot of them were presentations at DEFCON. Both protocols had the same amount of attention from researchers. Also both protocols had the same attack footprint because every web server also has an open ssh port and both protocols were exposed to attack attempts for the same number of years (arguably SSH has a longer track record than TLSv3) – slebetman Mar 06 '20 at 06:49
  • Yet even though servers expose themselves via TLS and SSH it is SSH that we depend on to protect our console access where we can literally run `rm -rf /` whereas we only use TLS to protect HTTP traffic – slebetman Mar 06 '20 at 06:51
  • Bringing FTPS (= FTP over TLS) into the discussion was a mistake. TLS/SSL and SSH are different protocols, as are SFTP and FTP. But SSH also supports certificates and the whole thing. –  Mar 06 '20 at 08:30
  • @GregSchmit uhm trusting CAs is a much bigger issue for me than manually verifying the fingerprint of an SSH server. Why? Because of the numerous issues that have popped up alone since the Snowden leaks. So unless that is my own CA, I'm not sure there's added trust here. But I guess it comes down to the same argument as PGP WoT versus S/MIME with CA-signed certificates. – 0xC0000022L Mar 06 '20 at 12:14
  • I think some of you are missing the point. If you want to audit your own CAs or even host your own, that's fine. The point is that TLS has a builtin automated system of certificate checking, whereas SSH does not have a builtin **automated** system of key checking. Most people (engineers at massive companies I've worked for) just type "y". Manual fingerprint checking is a bad argument because it assumes everyone in your organizational group will do it properly. – Greg Schmit Mar 06 '20 at 15:59
6

I'd say a lot of Unix commands become unsafe if you consider a MITM on SSH possible. A malicious sudo could steal your password, a malicious communication client could read your mails/instant messages, etc.

Saying that replacing scp with sftp when talking to a compromised server will somehow rectify the situation is very optimistic to say the least. Whatever damage scp can do to your local files can also be done from a binary file, shell script, Python file, Makefile, etc., and a rogue sftp will happily serve you these.

In short, if you don't pay attention to which servers you SSH into, there's a high risk for you to be screwed no matter which tools you use, and using sftp instead of scp will be only marginally safer.

This isn't to say that switching to sftp is a bad idea: if it's a superior tool for the task at hand, then you have a good reason to switch, which is, incidentally, not related to security.

JoL
  • 4,520
  • 15
  • 35
Dmitry Grigoryev
  • 7,123
  • 2
  • 23
  • 62
5

There's a lot of confusion about the new OpenSSH changes to scp made in response to CVE-2019-6111, and how safe they're supposed to make everything.

Their purpose is to prevent a rogue server used as source for the files from sending other filenames than requested, and overwrite random files on the local machine.

But they have no effect when the -r option is used. Using -r implies -T.

While perfectly logical, many people would fail to realize it, and they will be lulled in a sense of complacency by always expecting scp to check the filenames. Until they meet the hard truth, one day. The "security" offered by this is no better than alias rm='rm -i'.

Since it can be pretty convoluted to set up a rogue ssh/scp server just for testing, you can use the -S program option of scp (which directs it to use another program than ssh to set up the channel) to verify my claim.

Here I'm using a small executable script ssh_from_hell, which, no matter what asked for, always sends a lolcats.lol file:

$ chmod 755 ssh_from_hell
$ scp -S ./ssh_from_hell user@host:foo.txt .
protocol error: filename does not match request
    # OK, as expected

$ scp -S ./ssh_from_hell -r user@host:foo/ .
lolcats.lol                                   100%   12    62.0KB/s   00:00
$ cat lolcats.lol
LOL LOL LOL


$ cat ssh_from_hell
#! /usr/bin/perl
use strict;

$|=1;   # autoflush
sub readack { local $/=\1; <STDIN> }
sub ack { print "\0" }
my $data = join '', <DATA>;

readack;
printf "C%04o %lld %s\n", 0666, length($data), "lolcats.lol";
readack;
print $data;
ack;

__DATA__
LOL LOL LOL

Another infelicity brough about by the new changes is the fact that you can no longer quote the remote filename, instead of

scp 'user@host:"a file with spaces and * love *.txt"' .

you should use

scp 'user@host:a\ file\ with\ spaces\ and\ \*\ love\ \*.txt' .

However, some influential developers apparently love braces, so they have also added an ad-hoc pattern matching implementation with braces support to scp -- they could've probably used glob(3) with GLOB_ALTDIRFUNC|GLOB_BRACE, but it's always more fun to write new code. Anyways and fwiw, notice that the brace expansion implementation in scp is almost csh-like ie. {{foo}} will expand to foo:

$ scp -S ./ssh_from_hell 'user@host:{{lolcats.lol}}' .
lolcats.lol                                   100%   12    61.6KB/s   00:00

Yet not exactly the same as that from csh, perl and glob(3):

$ scp -S ./ssh_from_hell 'user@host:lolcats{}.lol' .
protocol error: filename does not match request

And also buggy:

$ scp -S ./ssh_from_hell 'user@host:lolcats{,}.lol' .
protocol error: filename does not match request
3

man scp

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.

You asked is scp unsafe? It can be, just like anything else not set up and used properly.

Man in the middle (MITM) vulnerability, you know that initial popup you get the first time ssh'ing to somewhere, the one you ignore and just click ok on...

the server's host key is not cached in the registry. you have no guarantee that the server is the computer you think it is. The server's ssh fingerprint is blablabla.

It is not SSH's (or scp's) fault. It is yours for not using the protocol properly.

Once you have established the ssh server your connecting to is who it's supposed to be, then it is a simple matter of (in my opinion) of using SSH protocol 2 and AES-256 cipher. That is the bulk of your security; if you don't tailor your sshd_conf (and the client ssh_config) and leave it defaulted then that's on you.

here's an except of an sshd_config you can ponder over

Protocol                                     2
Ciphers                                      aes256-ctr
MACs                                         hmac-sha2-512,hmac-sha2-256
# MACs                                       hmac-sha1
PermitRootLogin                              no
AuthorizedKeysFile                           .ssh/authorized_keys  {set this up}
IgnoreRhosts                                 yes
IgnoreUserKnownHosts                         yes
StrictModes                                  yes
UsePAM                                       yes

according to CVE-2019-6111

the scp client only performs cursory validation of the object name returned (only directory traversal attacks are prevented). A malicious scp server (or Man-in-The-Middle attacker) can overwrite arbitrary files in the scp client target directory. If recursive operation (-r) is performed, the server can manipulate subdirectories as well (for example, to overwrite the .ssh/authorized_keys file).

that is taken out of context. Don't connect to a malicious ssh server in the first place. Don't blame SSH for someone exploiting the protocol setting up their ssh server to overwrite arbitrary files in the scp client target directory. Make use of the server/client keys to establish the SSH connection properly in the first place and there's no MITM malicious server.

scp, which is ssh, is safe. Saying scp is not safe is inherently saying ssh should not be used because ssh is unsafe and that is not true.

SSH = secure shell

scp = secure copy over SSH

ftp = file transfer protocol

sftp = SSH ftp

ftps = ftp over TLS/SSL

Should scp be replaced by sftp?

when you can't be bothered by with the server's host key/fingerprint and just click ok, ask yourself how then is that ok with sftp (connecting to a server you have no guarantee is who you think it is).

once the SSH communication tunnel is established between two points, properly, the semantics of communication within be it secure copy or the file transfer protocol is trivial at that point. scp, which is ssh, is safe. Saying scp is not safe is inherently saying ssh should not be used because ssh is unsafe. And that is not true. If I call you on the phone, and you cause bad things to happen on my end, that's not the phone company's fault.

"The scp protocol is outdated, inflexible and not readily fixed. We recommend the use of more modern protocols like sftp and rsync for file transfer instead."

pleeeasssee.... rsync performs no encryption on its own, and you run into the same problem of no guarantee who you connect to is who you think it is. But in this insinuation rsync gets a pass? Careful of where you take recommendations from.

ron
  • 5,749
  • 7
  • 48
  • 84
  • Just because you know you're connecting to the server (or receiving a connection from the client) you think you are doesn't mean that the software on your end mediating and acting on traffic coming/going over that connection does only the precise things you intend it to. The biggest advantage of sftp is that it's built around a simple, clear specification. That makes reading and auditing code easier. – Charles Duffy Mar 06 '20 at 00:30
  • 3
    In any of these (sftp, scp, rsync), the authentication and encryption layers are unrelated to how operations and their results are serialized onto the wire -- you could run the sftp protocol over an unencrypted serial line if you wanted to, or the scp protocol as well. (Do the out-of-the-box clients make that easy? No, but that doesn't meat it couldn't be done). Which is to say -- I don't see the valid complaints as being about authentication and encryption in *any* of these cases. Minimizing implementation complexity to have code that can be comprehensively audited is key. – Charles Duffy Mar 06 '20 at 00:31
  • @CharlesDuffy "Do the out-of-the-box clients make that easy?" Yes, they do. Just use the `-S ssh-like-program` option. –  Mar 06 '20 at 08:02
  • 3
    "rsync performs no encryption on its own" -- What are you talking about? rsync uses ssh by default to connect to the server. – JoL Mar 06 '20 at 17:34
  • 3
    I also have to disagree with the idea that restricting the servers ability on what they can do with the client does not contribute to added security. You can say that scp is safe because ssh is safe, but it's not like safety is a black or white thing. `scp` is safer than `scp -T`. That's fact. – JoL Mar 06 '20 at 17:39
  • @JoL "on its own" is the key. Neither `scp`, `sftp` nor `rsync` do any encryption on their own. And please check my [answer](https://unix.stackexchange.com/a/571633/308316): `scp` is safer than `scp -T` just as `alias rm='rm -i'` makes `rm` "safer". That's __opinion__, not fact. –  Mar 07 '20 at 08:07
  • @mosvy The issue is not whether they technically implement the encryption themselves. The issue is that that paragraph makes it sound like there's no encryption/authentication at all when using rsync when it's actually the default behavior to include it. "you run into the same problem of no guarantee who you connect to is who you think it is" is false unless you explicitly ask of rsync to not give you a guarantee, because it uses ssh by default for encryption and authentication. – JoL Mar 07 '20 at 16:52
  • @mosvy Regarding `scp`, can you seriously argue that `scp` is less safe than `scp -T` under some circumstance? Or even that there is no circumstance where `scp` is safer than `scp -T`? I mean, if it's opinion, people should be able to have different opinions. Can you argue for an opinion different from "`scp` is safer than `scp -T`"? You can't even say that they're equally as safe because there are cases where `scp` is safer than `scp -T`, but not the other way around. – JoL Mar 07 '20 at 16:54
-4

They are not correct you are!

sftp is a derivative of ssh. I think he meant to not use FTP and use sftp.

SCP and sftp are running on top of SSH for the most part so if they want you to not use SCP they shouldn't want you to use SSH either (or sftp for that matter). Both sftp and scp allow secure file transfers, encrypting passwords and transferred data.

sftp can do some things that scp cannot but not security related as far as I know

Also SCP is faster than sftp is it uses a faster algorithms.

Links that show sftp is a derivative of ssh.

https://www.linux.com/tutorials/transfer-files-securely-sftp/

https://www.goanywhere.com/blog/are-ssh-and-sftp-the-same https://www.technology.pitt.edu/security/secure-shell-ssh-and-sftp

Mark Stewart
  • 726
  • 3
  • 8
  • 2
    Correct. Except that 1) SFTP is not a *derivative of SCP*. The protocols are completely different. 2) There are specifics of the SCP protocol what make its implementations more prone to some security bugs (see the comment by @Kusalananda). – Martin Prikryl Mar 05 '20 at 12:50
  • 2
    _"SFTP is a derivative of scp."_ -- have a source/reference/further explanation on that? _"SFTP can do some things that scp cannot"_ -- well, I don't doubt that, but it would be useful to mention at least some of those things. _"Also SCP is faster than sftp is it uses a faster algorithms."_ -- Citation needed. – ilkkachu Mar 05 '20 at 13:02
  • 2
    `scp` is a derivative of `rcp`. Neither has any code relationship to `sftp`, beyond both `scp` and `sftp` depending on the underlying `ssh` transport. – user4556274 Mar 05 '20 at 13:18
  • @ilkkachu "> SCP is faster than sftp -- Citation needed" [Here](https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#page-5) you go. `sftp` implements another layer of blocking/packets that should be acknoledged on top of that of the channel it runs over. You have sftp over ssh over tcp, each doing its own send/ack thing. Just add a bit latency to the mix. –  Mar 05 '20 at 13:54
  • I did make a mistake. I meant sftp is built on ssh. And I still stand by my comments. It has been corrected and some links to prove my point. – Mark Stewart Mar 05 '20 at 21:24